I think some of your confusion comes down to terminology. There are two separate characters, space " "
and tab "\t"
. Tabs are a single character, but get displayed as several blank columns. This can be configured with "shiftwidth". If you do :set shiftwidth=4
this means
When I press tab, insert a tab character, and display it as 4 blank columns (or as 4 spaces).
When you hit backspace, it deletes a single tab character that looks like 4 spaces. Now, if you want a tab character to insert 4 actual space characters, you should use expandtab
. If you :set expandtab
, it means:
When I press tab, enter tabstop spaces instead of a tab character.
So, if you :set tabstop=4
, the tab key will insert 4 spaces, and backspace will delete one of them at a time. For reference, here are the relevant lines in my .vimrc
:
"Indent settings
set autoindent
set expandtab
set tabstop=4
set shiftwidth=4
I also have:
filetype plugin on