0

I'm just looking for a very basic indentation scheme. In .vimrc I have :set tabstop=2. Adding :set smartindent has the effect of indenting the code by four tabs, very strange? A single tab the size of four spaces would be fine (despite my preferred tabstop), but four tabs? What is the issue here? :set cindent has the same effect.

edit: vim 7.4 on ubuntu 16.04

3

set tabstop=2 means tabs are displayed as at most 2 characters, it does not control the amount of indent. You have shiftwidth=8 which controls the amount of indent. When vim indents (assuming noexpandtab), it tries to use tabs first, hence you get 4 tabs of 2 apparent spaces each for a total of 4*2=8 spaces equivalent indent. The solution is to set shiftwidth appropriately

  • Note that setting 'shiftwidth' to zero means that the value for 'tabstop' will also be used for shiftwidth. – Rich Nov 22 '17 at 21:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.