Vim Recall繁體中文

Reindent the whole file

gg=G

Example

Normal 0 / 1
{
 one
   two
}
keep
Cursor on line 2, column 3

Apply indentation rules from the first line to the last.

Before & after
Before
{
 one
   two
}
keep
Cursor on line 2, column 3
After
{
  one
    two
}
keep
Cursor on line 1, column 1

Start in Normal mode. C indentation is enabled with expandtab and shiftwidth=2.

Details & Vim help

Example replayed in Vim

Apply indentation rules from the first line to the last.

gg moves to the first line, = begins the indentation operator, and G extends it to the last line. Results depend on filetype, indent settings, or equalprg.