Useful Vim Settings

Vim stores its settings in ~/.vimrc. Here are the ones that I generally find useful. Note that lines starting with " are comments.

Tip

After you make changes to .vimrc, you can apply them without restarting the Vim session with :source ~/.vimrc

" break compatibility with the ancient vi
set nocompatible
" set autorecognition of file types
filetype on
filetype plugin on
filetype indent on
" syntax highlighting, of course
syntax on
" smart context sensitive indenting
set smartindent
" show the info status bar at the bottom
set ruler
" show line numbers
set number

Turn on default capabilities for XML and DocBook file types.

autocmd FileType xml,docbk set omnifunc=xmlcomplete#CompleteTags

If you use tabs to edit several files at once, it is handy to map the the following shortcuts to switch between them.

" switch the tabs with SHIFT + < or >
map <S-Right> :tabnext<CR>
map <S-Left> :tabprevious<CR>