floreapaun
floreapaun

Reputation: 124

Why TAB inside VIM moves one space after exactly three-long characters words?

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.

Upvotes: 1

Views: 353

Answers (1)

Gus Brocchini
Gus Brocchini

Reputation: 67

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.

Upvotes: 2

Related Questions