0
set tabstop=2
set shiftwidth=2
set softtabstop=2
set expandtab
set autoindent

is in my .vimrc. However, my tabbing is inconsistent, sometimes resulting in a tab instead of 2 spaces. Am I missing something? This used to work before upgrading Ubuntu. I mainly program Python.

Thanks!

zallarak
  • 5,287
  • 7
  • 38
  • 54
  • 1
    In the future, please quantify "sometimes" by giving one example file and line number for which it fails and one example file and line number for which it works. – merlin2011 Apr 14 '15 at 18:38

1 Answers1

4

Set smarttab as well. I use set expandtab shiftwidth=4 softtabstop=4 smarttab

From vim's :help smarttab

When on, a Tab in front of a line inserts blanks according to 'shiftwidth'. 'tabstop' or 'softtabstop' is used in other places. A backspace will delete a 'shiftwidth' worth of space at the start of the line.

When off, a Tab always inserts blanks according to 'tabstop' or 'softtabstop'. 'shiftwidth' is only used for shifting text left or right shift-left-right.

What gets inserted (a Tab or spaces) depends on the 'expandtab' option. Also see ins-expandtab. When 'expandtab' is not set, the number of spaces is minimized by using Tabs. NOTE: This option is reset when 'compatible' is set.

AlG
  • 14,697
  • 4
  • 41
  • 54