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

How do you use a macro to prepend line numbers to each line?

Answer

qaI1. <Esc>jq

Explanation

Start at line 1, record a macro that inserts 1. at the start, moves down. Then use :let i=1 | g/^/s/^/\=i.'. '/ | let i+=1 for proper numbering.

Next

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