6

Occasionally I have a stray forgotten buffer in which I ran :diffthis. Later when I run :diffthis on some unrelated buffer that second buffer is immediately and unintentionally highlighted with the diff. At this point I don't know which buffer is the first in which :diffthis was run and I don't know how to :diffoff on that buffer.

How do I solve this? Can I simply :diffoff on all buffers, even buffers not in any window?

1 Answer 1

9

You can do this:

:bufdo diffoff

The :bufdo command runs a given command on all buffers. It works by cycling through all buffers and executing the command, so you will end up on the last buffer.

Caveat

From the help:

Note: While this command is executing, the Syntax autocommand event is disabled by adding it to 'eventignore'. This considerably speeds up editing each buffer.

This usually has the undesirable side-effect that syntax highlighting will be turned off in many buffers. When you switch to a buffer affected by this, you can simply run :edit (or :e for short) to trigger the Syntax autocommand that normally gets triggered.

Your Answer

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

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