Vim settings for whitespace

Indentation and whitespace alone can spawn whole religious wars with programmers. Some programs however have specific requirements or very strong ‘recomendations’ when it comes to tabs and whitespace so you may need to deal with both tabs and spaces for tabs.

Makefiles require tab characters as part of their syntax. Python strongly recommends you use spaces instead of tabs. In order to make sure that vim does the right thing when you edit these files you can add these commands to you .vimrc file,

autocmd FileType make set noexpandtab shiftwidth=8
autocmd FileType python set expandtab

This is in addition to your standard settings like autoindent,

set autoindent
set tabstop=4
set shiftwidth=4
set softtabstop=4

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s