I am trying to send a message to a running tmux window that is side by side, to tell it to run a script when I press a button. What I am trying to do is done by doing:

silent !tmux send -t 0.1 ruby test.rb ENTER 

Which will silently run the script. However, the display goes blank or glitches whenever I run this, and I than need to run the redraw! command to display the buffer again.

What would be the best way to convert these commands into a function?

:silent !tmux send -t 0.1 'ruby test.rb ENTER' 

so far I have tried doing the following, but I seem to be messing up somewhere:

silent !tmux send -t 0.1 ruby test.rb ENTER <CR> redraw! <CR> 
silent exec "tmux send -t 0.1 'ruby test.rb ENTER' | redraw!"

Overall, I am wondering what the best way to achieve sending messages to a tmux window would be and if this is a somewhat correct method, what is the proper way to build a vim function peicing that together?

  • I'm voting to close this question as off-topic because it appears to be more about tmux than vi/vim.
    – Herb
    Mar 19, 2017 at 1:45
  • @HerbWolfe The phrasing may be a bit off from what I'm trying to say, my bad. I'm more just looking to find out if there's a better way to send an external shell command from within vim and if not, how I can properly format it into a vimscript function.
    – Jack
    Mar 19, 2017 at 2:05
  • @Jack You may want to review this Vim Tips wiki entry: vim.fandom.com/wiki/… Feb 10, 2020 at 14:27

1 Answer 1


After messing around a bit more and looking over some stuff I was able to get this to work by wrapping the external command and its parameters in an execute command then using the bar to send the redraw command.

:execute  "silent !tmux send -t 0.1 'ruby test.rb' Enter" | :redraw!

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.