Right now, my VIM editor tab indent has some unusual behaviour.

When I am in insert mode and press tab, the cursor indents about 3 spaces instead of a whole tab indent. I like this.

When I high-light a block of text, then press SHIFT and > simultaneously, the block of text indents an entire tab indent instead of 3 spaces behaviour like above. I do not like this.

How do I make the second action behave like the first action?

link|improve this question
One is "ts" and the other is "sw", but I can't recall which is which. – Paul Tomblin Feb 13 at 1:38
:set tabstop=3 shiftwidth=3 with an optional expandtab or noexpandtab. shiftwidth must be the same as tabstop or someone will be cursing your indents. – hhaamu Feb 13 at 18:08
feedback

migrated from serverfault.com Feb 13 at 1:27

This question came from our site for system administrators and desktop support professionals.

1 Answer

Myself, I use:

set expandtab
set shiftwidth=4
set smarttab

This replaces tabs with spaces (expandtab), sets both the Tab and > to 4 spaces (shiftwidth). The smarttab settings allows for proper handling of Tab and Backspace based on the shiftwidth value. You can set shiftwidth to whatever you like.

link|improve this answer
feedback

Your Answer

 
or
required, but never shown