Vim-Tmux Runner

Vim-Tmux Runner

As the kind of person who is always looking for new ways to expand my development skills, I recently signed up for Thoughtbot’s Upcase service. Upcase is a “finishing school” for developers featuring screencasts, tutorials, exercises, and discussion forums. One of the first trail of videos I went through was a course on tmux by Chris Toomey.

I’ve experimented with tmux before, but I always thought it was a little too much for my needs; more trouble than its worth. But then I went through the tmux course on Upcase. One of the more interesting and useful things I got out of that course, was a vim plugin called Vim-Tmux-Runner.

Vim-Tmux Runner solves I problem I had with vim, while leveraging the power of tmux panes. It defines some vimscript commands that, when run from within a vim session, it sends the current line to be evaluated in an attached tmux pane. Here are some of my most-used vim keybindings for Vim-Tmux-Runner.

<leader>osr :VtrOpenRunner {'orientation': 'h', 'percentage':50}
# Opens new runner pane vertically split from the current vim session

<leader>t :VtrSendFile
# Sends current file to be run in attached runner pane
# will run file with appropriate command e.g. ruby <file>

<leader>va :VtrAttachToPane
# Menually attachs to an existing tmux pane

<leader>sl :VtrSendLinesToRunner
# Sends current line to runner for evaluation

Its a small thing, but it makes rapid development much easier. Especially when writing tests. Its definitely one of the little efficiency that makes complicated tools like tmux and vim worth learning.