How do I auto-indent the current line?
Answer
==
Explanation
The == command auto-indents the current line based on the surrounding context. It uses Vim's built-in indentation rules for the current filetype.
How it works
==adjusts the indentation of the current line- Uses the
indentexpror built-in C-style indenting - Works based on the file type and syntax
Example
if (true) {
return 1;
}
With the cursor on return 1;, pressing == indents it:
if (true) {
return 1;
}
Tips
=Gauto-indents from the current line to end of filegg=Gauto-indents the entire file=apauto-indents the current paragraph3==auto-indents 3 lines- In visual mode,
=auto-indents the selection