Is there a way to turn off syntax for only the current buffer/split windows? like for example, you can set map <buffer> or setlocal. Is there something similar for the syntax option ?

I use the :diffsplit command in vim quite a bit, for which I prefer to disable syntax and but this turns off highlighting for all buffers. I am using the following settings :

" turn off syntax when started from terminal
if &diff 
    syntax off
" turn off syntax when started from inside vim 
au OptionSet diff syntax off

1 Answer 1


Buffers and windows are different things.

To clear syntax for a particular buffer you can set the syntax option to empty string (or even simply do :syntax clear which should be the same for most purposes).

To clear syntax in a particular window you could use :ownsyntax off.

  • 2
    thanks that was helpful. :ownsyntax off does the trick. Is there a way to turn the syntax back on automatically after :q uitting from one of the windows using some kind of autocommand ?
    – First User
    Commented Nov 23, 2020 at 20:23
  • 1
    @FirstUser Obviously, &diff will be auto-reset after only single "diffed"-window remains open.
    – Matt
    Commented Nov 24, 2020 at 4:30

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.