5

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 ?

  • 2
    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. – Sato Katsura Sep 10 '16 at 21:03
  • I wonder how neovim approached that. – stdcall Sep 11 '16 at 19:21
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
        something.
  • Why is it implemented like that? I don't understand the motive. – stdcall Sep 12 '16 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). – Ingo Karkat Sep 12 '16 at 15:38
  • but it doesn't keep the output, the screen is blanked. that's why I ask. – stdcall Sep 12 '16 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. – Ingo Karkat Sep 12 '16 at 15:43

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.