Search code examples
gitvimbuffergit-diff

Opening a file in Vim opens vim diff?


When I open a file in vim, lets call it 'file1.rb', this file opens normally with ruby syntax highlighting and no problems up to this point.

When I open 'file2.rb' in a new buffer, it turns both of the buffers into vim diff.

I can switch buffers back and forth but what I'll see is a vim diff of the file open in each buffer. When I delete one of the buffers, I can use vim normally again without the vim diff color highlighting in the way.

At the moment I have only one buffer open at a time so that I don't run into this problem but I would like to have both of these buffers open at the same time with out it showing vim diff of the files.

Where can I disable this odd behavior, or any way I can stop this from happening?


Solution

  • Vim has a builtin command to disable diff mode, diffoff. From :help diffoff:

                                *:diffo* *:diffoff*
    :diffo[ff]  Switch off diff mode for the current window.  Resets related
            options also when 'diff' was not set.
    

    If you just want a quick fix, you can do this whenever you open a split, or even make a mapping or autocmd to make it easier. Perhaps something like

    autocmd BufNew * diffoff
    

    But this is definitely not the ideal fix.

    There's still the issue of what causes it. A quick glance through your .vimrc shows lots of plugins, but I don't see anything in particular that would cause it. I'm 90% sure the issue is from one of the plugins, so I would start there as you're looking for the problem. Also, this post over on the dedicated vim site will help you a lot: