vimtricks.wiki Concise Vim tricks, one at a time.

How do you use a macro to rename a variable throughout a function?

Answer

qa*Ncgn<C-r>=newName\n<Esc>q

Explanation

Record a macro using * to search for the word under cursor, cgn to change the next match, type the new name. Repeat with . or @a.

Next

How do you yank a single word into a named register?