Tips for Vim

Tips in this page are enabled by storing the corresponding commands in the user's Vim configuration file ~/.vimrc.

Adjust tab behaviour

To always use spaces instead of tab characters
set expandtab

To adjust the indent size
set shiftwidth=4

To make tab insert indents instead of tabs at the beggining of a line
set smarttab

To use a combination of spaces and tabs to simulate tab stops at a width other than the tab stop
set softtabstop=4

To adjust the size of a hard tab stop
set tabstop=4

Enable an 80 character layout

To show a limit at 80 characters
if exists('+colorcolumn')
set colorcolumn=80
else
au BufWinEnter * let w:m2=matchadd('ErrorMsg', '\%>80v.\+', -1)
endif