How do I shift-indent all lines from the current cursor position to the end of the file?
Answer
>G
Explanation
The >G command applies a right-indent shift to every line from the cursor through the last line of the buffer. It combines the > (indent) operator with the G (go-to-last-line) motion for a single, efficient keypress sequence.
How it works
>— the indent operator; right-shifts lines by oneshiftwidthG— the motion that extends to the last line of the buffer- Together they form an operator-motion pair, indenting all lines from cursor to EOF
Example
Given a file where the cursor is on line 3:
function setup() {
init();
call1();
call2();
call3();
}
Pressing >G from line 3 indents lines 3-6:
function setup() {
init();
call1();
call2();
call3();
}
}
Tips
- Pair with a count for multiple levels:
3>Gindents threeshiftwidthlevels at once - The complementary motion
<Gunindents from cursor to EOF - For indenting from the top down,
gg>Gre-indents the entire file (usegg=Gfor syntax-based auto-indentation instead) - Use
>.to re-apply the last indent operation, or.after any>command