re: What's your favorite Vim trick? VIEW POST

FULL DISCUSSION
 

There are a couple of tricks in Vim that I love.

  1. When renaming variables, I use ciw and rename the variable, at the next instance just press . to repeat
  2. zz to bring the current line the cursor is at in the middle of the screen (very useful) P.S. Not a trick but a highly recommend feature is relative line numbers. Helps me a lot
 

about your 1. there's another more awesome trick:

when renaming variables, you can search for it using / or * (reverse with ? or #) and use cgn (reverse cgN) to modify it, using . to change the next match.

The -gn movement is working on the next match. So you can spare one key (n or N) when bulk renaming variables.

tl;dr : Instead of

/foo<CR>ciwbar<ESC>n.n.n.

you can do:

/foo<CR>cgnbar<ESC>...

cheers 🍻

code of conduct - report abuse