I'm using Mac OS X 10.12 and I have set noexpandtab in my ~/.vimrc

There are 2 different behaviors :

  1. $ vim file.py

    If run Vim (8.0) to open one file and type :set expandtab?, it says expandtab

  2. $ vim

    If I run Vim by itself and type :set expandtab?, it says noexpandtab

Why is set noexpandtab in my ~/.vimrc ignored when I open a file ?

:verbose set expandtab? says:

      Last set from /usr/local/Cellar/vim/8.0.0627/share/vim/vim80/ftplugin/python.vim
  • 3
    You probably have a setting set only for python files. Use :verbose set expandtab? to find out where the setting was last set from.
    – Marth
    Commented Sep 8, 2017 at 10:00
  • 2
    you probably have a python plugin. Plugins can and will overwrite your vimrc. With Marth's comment you'll find out that this is the case. You can overwrite the settings again, with a file in ~/.vim/after/ftplugin.
    – B.G.
    Commented Sep 8, 2017 at 10:37
  • @DoktorOSwaldo Do I have to move my set noexpandtab in a file inside .vim/after/ftplugin/ directory ?
    – SebMa
    Commented Sep 8, 2017 at 12:14
  • yes, you could put it in a file called ~/.vim/after/ftplugin/py.vim or use an autocmd. look here stackoverflow.com/questions/28375119/…
    – B.G.
    Commented Sep 8, 2017 at 12:58
  • 1
    @SebMa ups sorry, of course it is python.vim ... can't edit my comment, but corrected it in my answer.
    – B.G.
    Commented Sep 11, 2017 at 5:50

1 Answer 1


It is not ignored, it is overwritten by your filetype plugin. In this case the python plugin. You can verify that like Marth said, with the :verbose command:

:verbose set expandtab?

If you want to overwrite the setting in the filetype plugin, you should go for one of the following ways:

  1. Put your settings in a after file: ~/.vim/after/ftplugin/python.vim, see :h after for more information.

  2. Use an autocommand: :autocmd FileType python setlocal noexpandtab, see :h auto for more information. *This must be done after the line which activates the filetype plugins (possibly something like :filetype plugin on)

Note the setlocal, you should use this instead of set in both, the autocmd and your after file. Else you can get it all mixed up if you open different filetypes in the same instance.

DISCLAIMER: Most Lines are directly taken from this SO post: Override options set by ftplugins in vim or the comment of Marth. This answer only adjust them for the given problem. So if this helped you, think about leaving an upvote there!

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