- Move your cursor over the variable you want to rename.
- Press
gdto go to the local declaration of the variable. - Press
cgnto change the text covered by the last search (the variable name, in this case). - Type the new name and press
<Esc>to return to normal mode. - Press
.to repeat the rename operation for the next occurrence of the variable. If you want to rename all occurrences in the buffer at once, you can use:%normal ..
Jedi-Vim’s Renaming
While your cursor is on a name: <leader>r (In case of using Jedi-Vim plugin for Python). Also, it does it across multiple files—project wide.