1
votes

After one-character length word or more than three-length characters word there TAB moves exactly 4 spaces. My .vimrc configuration file is it as it follows.

syntax on

" number of spaces moved along by pressing >>, << or ==
set shiftwidth=4

" number of spaces moved along by pressing the <TAB> or <BS> key
set softtabstop=4

set expandtab 

The tabstop configuration value is set to default, 8. I was expecting that TAB will move forward 4 spaces no matter what.

1
Can you show examples? Your description is not very clear. - Dan Lowe
Also you do not show the value of tabstop. Is it set to the default (8)? - Dan Lowe
It happens with me as well and my tabstop is set to default(8) - dlmeetei

1 Answers

2
votes

When indenting, vim inserts however many spaces it needs to get to the next multiple of shiftwidth.

In your case, shiftwidth=4, so vim inserts spaces until it gets to column 4: only one space.

If you want vim to instead blindly insert four spaces no matter what, try the following in your vimrc:

inoremap <TAB> <space><space><space><space>

That will make vim insert 4 spaces.