Convert tabs to spaces in Vim

Add the following to either ~/.vimrc, /etc/vimrc or /etc/vim/vimrc:</p>:

set tabstop=4       " The width of a TAB is set to 4.
                    " Still it is a \t. It is just that
                    " vim will interpret it to be having
                    " a width of 4.

set shiftwidth=4    " Intents will have a width of 4

set softtabstop=4   " Sets the number of columns for a TAB

set expandtab       " Expand TABs to spaces

To convert tabs to spaces in an already existing file, open it in vim and enter these:

:set expandtab
:retab