Indenting comments to match code in vim

It looks like you’re coding in Perl. Ensure that the following are set in your .vimrc:

filetype plugin indent on
syntax enable

These will tell Vim to set the filetype when opening a buffer and configure the indentation and syntax highlighting. No need to explicitly set smartindent since Vim’s included Perl syntax file will set it (and any other Perl-specific customizations) automatically.


Note: having either set smartindent and/or set autoindent in ~/.vimrc may prevent the solution from working. If you’re having problems, look for them.

Leave a Comment