auto indent in vim

329

$ vim ~/.exrc

set shiftwidth=4
set softtabstop=4
set nu

if has ("autocmd")
     filetype plugin indent on
endif

:wq

vim parse ~/.exrc on start,

shiftwidth & softtabstop makes sure that when ‘tab’ key pressed, it insert 4 spaces and when ‘backspace’ key pressed, delete 4 spaces.

 

‘nu’ print line number

 

‘filetype plugin indent on’ loads auto indent plugin for the file type (.extension) if avalable