I would like syntax to be turned off when I am in diff mode to focus only on the differences. I have the following code in my vimrc which works only when I start vim in diff mode from the command line :

if &diff
    syntax off
$ vim -d file1 file2 # works

But when I already have a file opened(file1) and would like to diff it with another file(file2) using the command :diffsplit file2, the code doesn't work and I have to manually turn it off.

I ran :echo &diff and it returned 1 meaning the code should be executed. Any ideas ? Thanks!

  • vimrc is sourced once upon startup. It should be obvious why it doesn't work as you expect.
    – Matt
    Nov 19 '20 at 10:11
  • 4
    use an OptionSet diff autocomd Nov 19 '20 at 10:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.