Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

One of my files has an incorrect tabstop setting

One of my files, whenever I open it, has a different (incorrect) value for the 'tabstop' option. In my .vimrc, I have the line:

set tabstop=4 softtabstop=4 shiftwidth=4 noexpandtab

and 'tab' is not mentioned in any subsequent lines. When I open a specific file I'm working on, the 'tabstop' option is set to 8, while all the other relevant options are correct; and all other files (so far) show their indentation correctly. I don't use modelines or smart tabs (yet). If I source my vimrc in the file, it corrects the indentation, so I'm assuming it isn't anything directly related to vimrc. What is happening?

like image 796
Zoey Hewll Avatar asked Dec 14 '25 20:12

Zoey Hewll


1 Answers

Basically there's two ways in which your .vimrc can be superseeded: plugins (including filetype-specific ones) might reset the option, or it might be changed by an autocommand. In any case, your first step is to check when the option was last modified (see :set-verbose):

:verbose set tabstop?

If that's not enough, look through the list of all the scripts and config files that Vim has read since it was started:

:scriptnames

(better do that in a newly started copy of Vim right after loading the offending file—this way, there'll be less output from :scriptnames.)

After these steps, you should have a list of scripts that might be the culprits. There's no easy way to narrow it down: you'll have to grep, to temporarily remove plugins from your ~/.vim and so on.

Finally you'll find a line that changes the setting. If it's in a plugin, look through its documentation to find a way to override the setting. If it's somewhere in the indent file or ftplugin, override its effect by placing a file into ~/.vim/after/indent/ or ~/.vim/after/ftplugin. An autocommand might also work.

like image 74
Alexander Batischev Avatar answered Dec 18 '25 04:12

Alexander Batischev



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!