10

When I used :silent to run a terminal command in the background, my vim screen goes blank, until I navigate through my code, at which point each line I move to reappears.

What gives?

2 Answers 2

10

This works as designed, and is documented under :help :silent:

      ":silent" will also avoid the hit-enter prompt.  When
      using this for an external command, this may cause the
      screen to be messed up.  Use |CTRL-L| to clean it up
      then.

You can also use the :redraw command.

1
  • 4
    I found I needed to use redraw! - without the bang it was like I'd done nothing
    – JonnyRaa
    Jan 30, 2018 at 10:38
0

For me, I found out that I couldn't use redraw to chain a command like this:

:!command | redraw

I tried with and without '!' i.e. 'redraw' or 'redraw!' with no luck : I always had to hit Ctrl-L to get my screen back.

I found a solution to this here and I did this instead:

:call system('command')

No need to call redraw.

For info, I was trying to send tmux commands to another pane from vim. Now my command, that I run when saving my buffer, looks like this:

:w | call system('tmux send-keys -t 1 "glow foo.md" Enter')

This obviously needs some more scripting and error checking, but you get the idea.

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.