Wednesday, April 18, 2007

VIM - Inserting spaces instead of tabs

Insert spaces instead of tabs

set expandtab or set et

Set the width of shifts to 4 for autoindenting and shifting: >> and <<

set shiftwidth=4 or set sw=4

Set where to stop tabs to 4

set tabstop=4 or set ts=4

This is what I have in my ~/.vimrc:

Set expanded tabs with shiftwidth=4 and tabstop=4 for Java, Perl, C, and C++ files

autocmd BufNewFile,BufRead *.java,*.pl,*.c,*.h,*.cc,*.cpp,*.hpp set sw=4 ts=4 et

No comments: