tips_and_howtos:vim_indent_with_comments

How to smart indent VIM with comment indenting

Vim tends to do nice indenting but wants to leave comments without one by default. This makes code look bad. This is a short reminder on how to make it right.

Set following to your ~/.vimrc :

filetype indent on
set autoindent

And that's it :)

If you've got a file that needs re-indenting open it with vim and issue following command :

:gg=G

And you've just indented the file.

Comments and suggestions

If you find bugs above please comment below. Also feel free to rate.

  • tips_and_howtos/vim_indent_with_comments.txt
  • Last modified: 2021/10/24 13:51
  • by 127.0.0.1