Vim Recall繁體中文

Number repeated lines in one gesture

V2j g<C-a>

Example

Normal mode on the first 0. Lines: 0. alpha, 0. beta, 0. gamma.

Before
0. alpha
0. beta
0. gamma
Cursor on line 1, column 1
  1. V2j Three lines selected · Visual Line mode
  2. g<C-a> Add 1, 2, then 3 · 1. alpha, 2. beta, 3. gamma
After
1. alpha
2. beta
3. gamma
Cursor on line 1, column 1
Details & Vim help

Visual g Ctrl-a applies progressively larger increments across selected lines.

Turn repeated zeroes into a numbered list.

Plain Visual Ctrl-a adds the same amount to each line. g Ctrl-a increases the amount on successive affected lines; use a count to change the step.

Try it in Vim

  1. Start on the first 0 in the example.
  2. Press V2j to select all three lines.
  3. Press g, then Ctrl-a.