vim Indentation


Example

Width

To make indentations 4 spaces wide:

:set shiftwidth=4

Spaces

To use spaces as indents, 4 spaces wide:

:set expandtab
:set softtabstop=4

softtabstop and sts are equivalent:

:set sts=4

Tabs

To use tabs as indents, 4 spaces wide:

:set noexpandtab
:set tabstop=4

tabstop and ts are equivalent:

:set ts=4

Automatic Indentation

:set autoindent

Instruction descriptions

InstructionDescriptionDefault
tabstopwidth of tab character8
expandtabcauses spaces to be use instead of tab characteroff
softabstoptune the whitespace0
shiftwidthdetermines whitespace amount when in normal mode8