vimtricks.wiki Concise Vim tricks, one at a time.

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 one shiftwidth
  • G — 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>G indents three shiftwidth levels at once
  • The complementary motion <G unindents from cursor to EOF
  • For indenting from the top down, gg>G re-indents the entire file (use gg=G for syntax-based auto-indentation instead)
  • Use >. to re-apply the last indent operation, or . after any > command

Next

How do I inspect a Vim register's full details including its type (charwise, linewise, or blockwise) in Vimscript?