When I'm executing an external command in silent mode in vim, when it returns the screen is blank and I need to redraw it.

Here's how I solve it in the .vimrc

nnoremap <F5> :silent :make<CR>:redr!<CR>

without the redr! the screen is blank and I have to press Ctrl+lin order to continue.

Is it a bug, or a feature ?

  • 3
    The design of Vim is really old. What's going on when you run :make is complicated. On some systems you can fix the flicker, on others you can't. If your Vim's shell is bash you might try setting shellredir to &>. This works in text mode on most Linux systems (not all), and doesn't work in graphics mode, and on most FreeBSD and OpenBSD systems. Sep 10, 2016 at 21:03
  • I wonder how neovim approached that.
    – stdcall
    Sep 11, 2016 at 19:21

2 Answers 2


This is by design. The :help :! (a closely related command) offers this:

        Vim redraws the screen after the command is finished,
        because it may have printed any text.  This requires a
        hit-enter prompt, so that you can read any messages.
        To avoid this use:
            :silent !{cmd}
        The screen is not redrawn then, thus you have to use
        CTRL-L or ":redraw!" if the command did display
  • Why is it implemented like that? I don't understand the motive.
    – stdcall
    Sep 12, 2016 at 14:36
  • Vim doesn't know whether the command actually did output (only the terminal knows). Doing a redraw just in case would be wasteful (and flicker). So they leave this up to the user (who should know about the command). Sep 12, 2016 at 15:38
  • but it doesn't keep the output, the screen is blanked. that's why I ask.
    – stdcall
    Sep 12, 2016 at 15:38
  • Right. So a redraw would be necessary, unless you move the cursor, split a window (which redraw implicitly), or issue another external command (and only redraw when done). I'm also only guessing here. I see your point of this not making much sense, but there are several bad defaults (based on its long history) in Vim. Sep 12, 2016 at 15:43

I had a similar problem myself, and while your own solution worked for me, I believe you could also use this plugin.

Here the short description:

 This plugin ensures that the output of external commands run in Vim stays in Vim's "virtual screen", and doesn't pollute your main "shell screen".

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.