2

I'm using tmux and Vim as my development IDE. I have 3 panes open in tmux: one for editing source code, one for debugging and one as a display console.

From Vim I would like to run the make command and send all the build information emitted by it to the display console pane. How would I do that?

2

You can run any shell command from one pane and display its output in another pane with the run-shell command. For example:

tmux run-shell -t 2 "echo hello"

...and "hello" will be printed to pane number 2. You can see pane numbers with prefix + q.

From vim you should be able to do:

:!tmux run-shell -t 2 "make ..."

Add -b to run the command in the background.

Update: Addressing a couple things that @SLN brought up in this comment...

  • tmux puts the output pane into copy-mode, the same mode it is in when you do scrolling, so break out of it however you normally do (Ctrl+C is one way). Note: you'll know you're in this mode if you see something like [12/34] (i.e. page-num/total-pages) in the upper-right corner of the pane.
  • As for Vim requiring you to hit Enter (or Ctrl+L) after make or other command completes, this is just how Vim works with external commands (:!cmd). I'm not aware of any way to avoid this but I believe you can hit Enter before the command finishes and it will return as soon as it's done. (This might be system dependent.)

Update 2: I do know a workaround for the second item. If you use a mapping to run the external command you can embed an exit key. Here's an example where I'm just doing ls as my shell command:

nnoremap <leader>ls :!ls<CR><C-L>

From Normal mode I hit \ls and the ls command will run but then the console output will close and return me to vim right away. Perhaps you can adapt to this whatever your command is.

  • @B Layer, Seem working for me, but after I run the run-shell command the with the background in my vim, it still print some information to me, I have to tap Enter key to get back to vim, is this normal? Another issue is the run-shell command seems has frezzed my 2nd pane, how can I jump out the frezze mode? Thanks – SLN Jan 12 '18 at 9:38
  • 1
    @SLN see my updated answer. – B Layer Jan 12 '18 at 10:20
0

You can touch a file in advance & tail -f file : it in one pane ... so inside vim launching the make with redirection of output to that file it will display your make session ....

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.