1

I often want to diff more than 4 files, but I run into E96: Can not diff more than 4 buffers. This limit seems to be compiled into vim, and it also seems rather arbitrary.

Is there anything I can do to fix this?

I found here that I'd need to change DB_COUNT, but that thread is two years old and it doesn't look like they actually tried to implement that fix.

Would it work? Would it break anything?

  • 3
    Why don't you simply try it? – romainl Aug 22 '16 at 14:29
  • No, nothing has changed since then. You need to recompile Vim as I said in the thread mentioned. – Christian Brabandt Aug 22 '16 at 18:23
1

Changing DB_COUNT in structs.h does indeed work, and so far, I haven't run into any issues. Here's the git diff of my change:

diff --git a/src/structs.h b/src/structs.h
index 4488bf8..7524bd1 100644
--- a/src/structs.h
+++ b/src/structs.h
@@ -2296,7 +2296,7 @@ struct file_buffer
 /*
  * Stuff for diff mode.
  */
-# define DB_COUNT 4    /* up to four buffers can be diff'ed */
+# define DB_COUNT 16   /* up to four buffers can be diff'ed */

 /*
  * Each diffblock defines where a block of lines starts in each of the buffers

Update: This has now been added to Vim in patch 7.4.2251. However, it has only increased to 8, not to 16. If you need it to be higher than 8, you'll still need to increase DB_COUNT and compile Vim yourself.

  • you should have changed the /* comment */ as well, it is misleading this way – törzsmókus Feb 15 '18 at 11:50
  • True, and there's also some documentation that needs to be changed. If you want to create your own patch to up it to sixteen, I'd suggest basing it on this commit. – rchard2scout Feb 15 '18 at 13:17

Your Answer

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

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