13

I did :vert diffsplit file1.txt, then realized I didn't want to diff it but a different file. So I closed one window with :q and turned off the diff highlighting with :diffoff.

I then tried :vert diffsplit file2.txt, but now if I try to dp or do to put/get changes, I get the E101: More than two buffers in diff mode, don't know which one to use error.

How do I avoid this, or what am I doing wrong?

Mateusz Piotrowski
  • 8,029
  • 10
  • 53
  • 79
keflavich
  • 18,278
  • 20
  • 86
  • 118

3 Answers3

14

You should switch off diff mode for the unwanted buffer with :diffoff before quitting it with :q. Depending on your settings (e.g. :set hidden), the buffer will persist in the buffer list (:ls), and Vim will consider it when doing a diff.

A :bufdo diffoff should turn off diff for all existing buffers, though I usually just quit Vim and relaunch it with vimdiff ... should such a situation arise.

Ingo Karkat
  • 167,457
  • 16
  • 250
  • 324
  • I sometimes to diffs within gvim with many other tabs open. My normal solution for vimdiff was just to quit, but for gvim that's not ideal. Thanks! – keflavich Nov 07 '12 at 14:54
  • 2
    Before quitting any of the windows execute `:diffoff!` or `:diffo!` for short. This will turn diff mode for all the windows in the current tab page. See `:h :diffo` – Peter Rincker Nov 07 '12 at 19:26
  • I tried doing :diffoff! and it still did not work. Had to do :buffo diffoff. Once I did that, I found that the buffer in my left split was still in diff mode. So on that buffer I did a :diffoff and then was able to do :diffthis in two other buffers successfully and make changes. – Brian Jun 30 '14 at 17:10
4

Note the buffer number which you want to put/get the changes by :ls command.

Then prefix your put/get command with the buffer number of your choice, e.g. 2dp.

J. Scott Elblein
  • 4,013
  • 15
  • 58
  • 94
kenorb
  • 155,785
  • 88
  • 678
  • 743
3

This may be kind of late reply but still for future feference

i do

:tabdo diffoff!
justrajdeep
  • 855
  • 3
  • 12
  • 29