Add the following to ~/.vimrc, /etc/vimrc or /etc/vim/vimrc:
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


5 comments:
Many thanks, that was very useful.
thanks a ton man
That is a really good solution, it is non-intrusive, non-destructive, and ensures that files edited going forward will have an un-tabbed state.
The :retab command rocks.
Thanks!!!!!
was very helpful... thanks
Thanks for posting this!
Just what i was looking for :)
Post a Comment