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, 2016 at 14:29
  • No, nothing has changed since then. You need to recompile Vim as I said in the thread mentioned. Aug 22, 2016 at 18:23

1 Answer 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 Feb 15, 2018 at 11:50
  • 1
    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. Feb 15, 2018 at 13:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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