I'm trying to understand using the autocmd to modify properties for certain files. Here is a basic example I have in my vimrc:

syntax on
autocmd BufRead *.py syntax off

However, when I then open up a new python file, all files in that window (whether python or not) have their syntax highlighting removed. For example:

enter image description here

Why does this occur, and what would be the proper way to change something for only the filetype I'm referencing and not other windows/splits?

Note: the same thing also happens with:

autocmd FileType python syntax off

From Learn Vimscript the Hard Way:

One of the most useful events is the FileType event. This event is fired whenever Vim sets a buffer's filetype.

But if the user has to manually set the ft everytime a file is opened, it seems quite useless (if I'm understanding things correctly).

1 Answer 1


The :syntax command is global. Probably you're looking for the "local to buffer" setting 'syntax' (abbreviation: 'syn'). To disable for current file:

set syn=OFF

per :h 'syn' though set syn= and set syn& seem to work, too.

You can use this with a filetype auto command like so:

autocmd FileType python set syn=OFF

Each time you open a Python file it should be without syntax highlighting.

(I wouldn't be surprised if there were other ways to accomplish this but I verified the above works.)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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