Search code examples
vimvim-plugin

How to force an option after it has been overriden by vim plugin?


I have classic settings to expandtab in my /etc/vimrc:

set expandtab
set tabstop=4
set shiftwidth=4

How do I make sure they are not overridden by ANY plugin?

How to force them ignoring ALL plugins?

Settings in /etc/vimrc are overwritten by language-specific settings. I want the opposite - any language-specific settings is overwritten by my settings in /etc/vimrc.

I appreciate the "smart" setting by filetype, but they have just got too smart - the default vim setup sets noexpandtab on some unrelated files. Even if I can find the culprit plugin, I don't want to fix them one by one - there is always a chance some new plugin will mess things up again. I would rather live with accidental spaces (where tabs are expected) then otherwise.


Solution

  • The only ways to satisfy your requirements while still enabling filetype plugins I could think of involve overriding every possible filetype plugin.

    The simplest is probably to do it in /etc/vimrc with an autocommand:

    augroup expandtabFTW
        autocmd!
        autocmd FileType * setlocal expandtab
    augroup END