I'm using console vim within a tmux window, therefore occasionally vim doesn't recognize that files have been modified (gvim does it on a focus change AFAIK) and in order to avoid getting inconsistent buffers, I manually ask vim to reload them all using

:bufdo :e

However, after this syntax highlighting is lost in all the buffers. Typing :e in a buffer then restores it again. This seems strange, as I'd suppose that :e behaves the same when given directly and when inside :bufdo. Is there a way how to get around that, to have syntax highlighted buffers after :bufdo :e?


3 Answers 3


What you are experiencing seems to be a feature. From :help bufdo:

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

Nevertheless, you probably should focus on which settings you are using on gVim that you are missing on console Vim, as they should be able to behave in the exact same way. If you really need to reload all the buffers, you should try the :checktime command.

  • AFAIK gVim does an additional check when the window holding a file gets focus. This helps to discover changed files early, as most often they're changed as the result of a user action elsewhere.
    – Petr
    Commented Oct 22, 2015 at 15:11
  • 1
    Thanks for pointing me to :checktime, I found this answer on SO which suggests a solution.
    – Petr
    Commented Oct 22, 2015 at 15:13
  • 1
    @PetrPudlák very few features are restricted to the gui version (mostly font and other display options). It is more likely that you have some option (such as 'autoread') or autocmd (such as FileChangedShellPost), or that the versions of Vim and gVim are different. You can compare the options using :set and autocommands using :au and redirecting the output as explained in this question.
    – mMontu
    Commented Oct 22, 2015 at 16:59
  • I found it: In :help timestamp (my emphasis): After a shell command is run (:!cmd suspend :read! K) timestamps, file modes and file sizes are compared for all buffers in a window. Vim will run any associated FileChangedShell autocommands or display a warning for any files that have changed. In the GUI this happens when Vim regains input focus.
    – Petr
    Commented Oct 22, 2015 at 17:25
  • @PetrPudlák maybe I missed something, but my understanding is that the same behavior (autocommands or warnings) occurs both on console and GUI; in the GUI the behavior is postponed until it gain focus.
    – mMontu
    Commented Oct 22, 2015 at 19:08
:execute 'bufdo :e' | source $VIMRUNTIME/syntax/syntax.vim
  1. execute is a workaround, so that the command following | is not included in the bufdo
  2. sourcing this file is mentioned in :he :syntax-enable
  • 2
    Much simpler would be to instead use :execute 'bufdo :e' | syntax on, no need to source any files.
    – Ruslan
    Commented Aug 29, 2019 at 16:16
  • 1
    @Ruslan that would be much simpler, but it doesn't work, at least not for me with Neovim. The longer version shared by cdosborn worked fine, though.
    – Desty
    Commented May 22, 2020 at 21:38

If you want to reload all buffers before :lvim or something to make sure that vim doesn't use stale versions of files:

:bufdo se ei= | e

It resets eventignore (which bufdo sets) before reloading a buffer.

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.