vimautocommand

.vimrc autocommand if NOT filetype


I have a master .vimrc that sets up my global working environment, including special setup for both C++ and Python filetypes.

In a project folder I have an .exrc with project-specific settings for C++, but this is overriding my master .vimrc settings for Python.

How can I create an autocommand that sets these options only if it is not a python file? I don't want to wrap the project C++ settings in an autocommand because we have multiple source file types and that means a lot of duplicated code in .vimrc as well as the potential to miss a file type.

What I really want is a construct like this:

if Filetype python then
   ...
else
   ...
endif

But it would be sufficient to simply do this:

if not Filetype python then ...

Solution

  • if &filetype != 'python'
    

    &filetype gets the value of the current file type.