Re:A Vim Guide for Advanced Users
by edanm on Sunday February 28, 2021 @02:02AM
(#26291260)
Yes, and here's my favorite vim trick I ever invented - you can do use this after changing a word.
What I mean is: if I'm on a (say) a variable name, and I change it with "cw", then realize I actually need to change it in a few more places, I can use a little shortcut to change it in those places, without even thinking of it beforehand.
The shortcut is:
" Make <leader>. repeat the last "change word" command.
nnoremap <leader>. :let @/=@"<cr>/<cr>cgn<c-r>.<esc>
After any change command, just hit <leader>. to repeat it. You can thereafter hit "." to repeat again.
What I mean is: if I'm on a (say) a variable name, and I change it with "cw", then realize I actually need to change it in a few more places, I can use a little shortcut to change it in those places, without even thinking of it beforehand.
The shortcut is:
After any change command, just hit <leader>. to repeat it. You can thereafter hit "." to repeat again.