tags:

views:

309

answers:

5

Hi folks:

My current setting assumes 8 spaces; how could i redefine it?

Thanks.

+9  A: 

Depending on what you mean by tab, one of the following should work:

" size of a hard tabstop
set tabstop=4

" size of an "indent"
set shiftwidth=4

" a combination of spaces and tabs are used to simulate tab stops at a width
" other than the (hard)tabstop
set softtabstop=4

You may also want to try the following:

" make "tab" insert indents instead of tabs at the beginning of a line
set smarttab

" always uses spaces instead of tab characters
set expandtab

See :help 'optionname' (eg: :help 'tabstop') for more details on any of these.

Laurence Gonsalves
+8  A: 
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    " Indents will have a width of 4

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

set expandtab       " Expand TABs to spaces
Alan Haggai Alavi
+3  A: 
:set sw=4

Mastering VI editor

Amarghosh
+6  A: 

or shorthand for vim modeline:

vim :set ts=4 sw=4 sts=4 et :
zen
A: 

To make any of the above permanent you can put them in a .vimrc file in your home directory (or _vimrc) on Windows.

Brian
... as well as in any other OS.
Martin Hohenberg