Move a line to an exact position
:3m0
Example
Normal mode. Lines 1–3: alpha, beta, gamma.
alpha
beta
gamma- :3m0<CR> Move line 3 above line 1 · gamma, alpha, beta
gamma
alpha
betaDetails & 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
- Type :3m0<CR> in the example.
- 3 selects gamma; 0 places it before line 1.
- Use :m+1 to move the current line below the following line.