My ~/.vimrc contains:

set tabstop=4
syntax on
set number
set noswapfile
set hlsearch
set ignorecase
set incsearch
set autoindent
filetype plugin indent on

When I didn't have the last two lines, tab spacing was 4, as required. But when I used the last two auto-indenting lines, tab has been set back to 8 spaces. It seems like something about the last two lines overrides the tabstop parameter. Any fix for this? Vim is latest version 8.1 in ubuntu 20.04.


When you enable filetype plug-ins, Vim will load filetype-specific configuration whenever it opens a file of a specific type. Many such plug-ins are shipped with Vim itself and you can find them under directories such as indent/ and ftplugin/ in your Vim runtime (you can find the location with :echo $VIMRUNTIME inside Vim.)

So it's quite possible that you're editing a filetype for which Vim has configuration to override the tabstop.

You can find where exactly that setting is coming from using the following command:

:verbose set tabstop?

(You can shorten it to :verb set ts?.)

This command will tell you what the current tab stop setting value is, but it will also tell you where it was last set. You can then inspect the script where it was set, to try and understand why that happened.

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.