Vim: Change tabs to spaces and set how many spaces on tab press

In short:

set expandtab
set tabstop=4
set softtabstop=4
set shiftwidth=4

When you press tab in vim, you normally get a tab character inserted in your text.

You can turn this off via set expandtab. When you press tab now, you get spaces.

To alter how many spaces you get on tab press, issue set tabstop=4. If you use expandtab you should set softtabstop=4

Finally, to alter how to spaces you get when you indent text with >, issue set shiftwidth=4.


Edit on github
comments powered by Disqus
Click me