Indent text in vim

Using VISUAL mode

before you want to ensure you prefer TABs or SPACEs (and you not prefer TABs).

set expandtab

Define depth of indention.

:set shiftwidth=2

Enable VISUAL mode V, select text, press >

without VISUAL mode

Enable numbering

:set number

Command below will indent lines 9--16 by width configured above.

9,16>

(I use it to correct 2 spaces into 4 spaces.)

undo is your friend, press u


Revision #1
Created 14 September 2026 08:22:11 by Anton
Updated 14 September 2026 08:29:11 by Anton