February 5, 2012

Yesterday I changed my ~/.vimrc to make programming in a terminal easier. For years now I’ve been reusing the same one.

Here it is with comments:

" Turn on syntax highlights. Well it's not an IDE, but makes important things stand out enough
syntax on
" Make tab width 4 spaces
set tabstop=4
" Make indent width also 4
set shiftwidth=4
" Make indent rounded to next full shift width
set shiftround
" Expand tabs to spaces (doesn't mess up file indentation in other editors width different tab settings)
set expandtab
" Indent code blocks automatically (don't need to type a lot of tabs in deep indented lines after a linebreak)
set autoindent
" And make backspace delete smartly (like in any editor. through indents, linestarts and end of lines)
set backspace=indent,eol,start

And finally a command to remember to replace all tabs with spaces based on the values above. (Good for formatting text made in another editor)

:retab or :retab! to force replacing all tabs which are not surrounded by whitespaces