normal·mode
~ / macros / numbered-listslesson 5/6

Counting with CTRL-A

Number lines with a copy-and-increment macro, or with g CTRL-A in Visual mode.

3 drills

  1. Copy and count up: Turn the single line into the numbered run in the target. Record yyp<C-a> (copy the line below, bump its number) into register a, then replay it until the last number in the target.
  2. Make the ones count: Every item says 1. Select from the second item to the last one with V and press g<C-a>, so they count up.
  3. Number plain lines: Number these lines. Put a 0 prefix on every line with a block insert, reselect the block with gv, and let g<C-a> count them up from 1.

The drill editor loads in your browser.

outside the editor the page is in normal mode: ? keymaps · / find · : commandsfound this useful? ☕ support it ·credits · source · not affiliated with Vim or Neovim