Vim Recall繁體中文

Move a line to an exact position

:3m0

Example

Normal mode. Lines 1–3: alpha, beta, gamma.

Before
alpha
beta
gamma
  1. :3m0<CR> Move line 3 above line 1 · gamma, alpha, beta
After
gamma
alpha
beta
Details & Vim help

Relocate a line or range without cutting it into a register.

Reorder lists with explicit source and destination addresses.

The destination is evaluated as an address and the lines are moved after it. A destination inside the source range is invalid except its last line, which leaves the text unchanged.

Try it in Vim

  1. Type :3m0<CR> in the example.
  2. 3 selects gamma; 0 places it before line 1.
  3. Use :m+1 to move the current line below the following line.