Sagar Jain
Sagar Jain

Reputation: 7941

Indent lines as I type in vim

I know that gg=G is one of the simplest and easiest commands to indent lines in vim.

But, is there a way to indent lines as I type and press Enter?

Upvotes: 0

Views: 103

Answers (1)

Zach
Zach

Reputation: 4792

Yes. Add the following to your vimrc:

set autoindent
filetype plugin indent on

Autoindent just indents based on the previous line's indentation if it does not know how to indent. Filetype indentation uses some things vim knows about what kind of programming language you are writing in to indent it correctly. Filetype indentation will override autoindentation.

Upvotes: 6

Related Questions