How do I indent selected lines in visual mode?
Answer
>
Explanation
In visual mode, pressing > indents all selected lines by one shiftwidth. This is the simplest way to adjust indentation for a block of code.
How it works
- Select lines with
V(or any visual mode) - Press
>to indent one level - The selection is deselected after the operation
Example
if (true) {
return 1;
return 2;
}
Select lines 2-3 with Vj, press > to indent:
if (true) {
return 1;
return 2;
}
Tips
<dedents the selectiongv>reselects and indents again.repeats the indent (but on the current line only)=auto-indents the selection based on file type>>indents without visual mode