Fork me on GitHub
#spacemacs
<
2019-09-29
>
Drew Verlee01:09:47

I assume the best way to rename a function/defn is using clj refactors change symbol name. Are there other ways? The podcast mentions iedit, that's a text based replacement right?

practicalli-johnny07:09:34

@drewverlee Yes, you can use iedit to rename multiple instances of text in a buffer. In Evil normal mode, if the cursor is on a symbol name, like a function name, def or let binding, then pressing * or ‘#’ will highlight all instances and show the symbol transient menu. Pressing e will take you into iedit mode (turning the cursor red). Or you can just use / to search You can then edit the highlighted text as normal and all other instances change at the same time. Use narrowing before selecting / searching to be more selective in what text is show and therefore highlighted and changed. E.g. if you just want to change a specific function or range of text. If you want to change text throughout a project, then press * or ‘#’ to show the symbol transient menu. Use project search by selecting / which will display all matches throughout the project. C-z will give you a list of actions you can perform on the results of the project search F4 will open the results in a new buffer for editing. Now we can use iedit again, SPC s e, on any text we select in the project search results. Or simply manually edit the file (or even use multiple cursors). C-c C-c will commit the changes you have made, updating the changes throughout all the relevant files in the project.

jumar08:09:26

SPC * is what I use most of the time

practicalli-johnny10:09:23

Interesting, so you can use SPC * instead of * and then / to open the project search on that symbol. Thanks.

Drew Verlee14:10:15

thanks!. Right now i seem better at using projectile-replace. But ill look more into iedit.

practicalli-johnny14:10:45

SPC p R for projectile-replace looks very handy, especially when its a simple case of replacing one name with a new one. Using helm-ag and iedit has a few more steps but can manage more complicated replacements, but most of the time replace should be just fine.

spfeiffer05:09:48

@drewverlee I can only recommend updating to recent develop and using clj-kondo.

euccastro05:09:48

I have spacemacs develop installed and cider-version says CIDER 0.18.1snapshot (package: 20180923.1759) but in the cider github project page I see that the melpa stable version is 0.22.1. is that normal? for example, I don't seem to have cider-clojuredocs even though it's bound to ,hd in spacemacs

euccastro05:09:05

nevermind, I just noticed the Update Packages thing in the spacemacs buffer 😳

bananadance 4
practicalli-johnny07:09:34

@drewverlee Yes, you can use iedit to rename multiple instances of text in a buffer. In Evil normal mode, if the cursor is on a symbol name, like a function name, def or let binding, then pressing * or ‘#’ will highlight all instances and show the symbol transient menu. Pressing e will take you into iedit mode (turning the cursor red). Or you can just use / to search You can then edit the highlighted text as normal and all other instances change at the same time. Use narrowing before selecting / searching to be more selective in what text is show and therefore highlighted and changed. E.g. if you just want to change a specific function or range of text. If you want to change text throughout a project, then press * or ‘#’ to show the symbol transient menu. Use project search by selecting / which will display all matches throughout the project. C-z will give you a list of actions you can perform on the results of the project search F4 will open the results in a new buffer for editing. Now we can use iedit again, SPC s e, on any text we select in the project search results. Or simply manually edit the file (or even use multiple cursors). C-c C-c will commit the changes you have made, updating the changes throughout all the relevant files in the project.

practicalli-johnny08:09:21

The symbol highlight transient state is a really useful menu for finding names of things https://practicalli.github.io/spacemacs/navigating-code/names-symbols.html

practicalli-johnny10:09:22

Interesting, I just noticed if you did TAB on a function name it lists all the matching functions. For example, i pressed TAB when the cursor was on reduce and a helm popup appeared listing a search of all matching functions in Clojure core. That's nice.

practicalli-johnny10:09:12

Ah, if you select one of the alternative functions listed in the helm popup it replaces it for you (just at the cursor though)