Of course the fact that you can refactor on IDEs is priceless for many, I hardly ever do it when I am coding but I may try to do it when editing some one else\'s source. How do
There is another vim plugin dedicated for refactoring called factorus which is available on github.
Currently (2017-12), it supports the languages
- Rename
- Extract Function
- Extract Local Variable
- Toggle var ⇔ :=
- Add Godoc stubs
There is a vim plugin https://github.com/godoctor/godoctor.vim which makes them available
With cursor in thing to rename:
:Rename <newname>
Highlighting block to extract:
:Refactor extract newfunc
vim-go
:GoRename
.Language server gopls
I write a lot of C/C++ code in vim. The most common refactoring that I do is renaming variables, class names, etc. Usually, I use :bufdo :%s/source/dest/g
to do a search/replace in files, which is almost the same as renaming provided by big IDE's.
However, in my case, I found that I usually rename similar entities, spelled in different cases (i.e CamelCase, snake_case, etc.), so I decided to write a small utility to help with this kind of "smart-case" search/replace, it is hosted here. It is a command-line utility, not a plugin for vim, I hope that you can find it useful.