It should be trivial, and it might even be in the help, but I can't figure out how to navigate it. How do I indent multiple lines quickly in vi?
Indent multiple lines quickly in vi
editorindentationvivim
Related Topic
- Vim delete blank lines
- Your most productive shortcut with Vim
- Copy all the lines to clipboard
- What’s a quick way to comment/uncomment lines in Vim
- Turning off auto indent when pasting text into vim
- How does the vim “write with sudo” trick work
- Vim: insert the same characters across multiple lines
- Find and replace strings in vim on multiple lines
Best Answer
Use the > command. To indent five lines, 5>>. To mark a block of lines and indent it, Vjj> to indent three lines (Vim only). To indent a curly-braces block, put your cursor on one of the curly braces and use >% or from anywhere inside block use >iB.
If you’re copying blocks of text around and need to align the indent of a block in its new location, use ]p instead of just p. This aligns the pasted block with the surrounding text.
Also, the
shiftwidth
setting allows you to control how many spaces to indent.