Skip to content Skip to sidebar Skip to footer

Key Bindings To Send Lines Of Test Code With Tmux+vim?

I am trying to create an ide-like setup with tmux + vim. I've seen a lot written about this on the internet, but I've been unable to figure out how to do one critical thing: execut

Solution 1:

I think https://github.com/jpalardy/vim-slime is what you are be looking for.

Once installed and configured (tmux is not the default used, screen is), you can execute the text under the cursor with <C-c><C-c>.

The following worked for me:

  • Install Vim-slime. I'm using Vundle, so I added the following to my .vimrc: Plugin 'jpalardy/vim-slime', and ran :PluginInstall in vim.

  • Configure slime for tmux by adding the following to your .vimrc: let g:slime_target = "tmux"

  • Try sending a line with vim-slime with the default key-binding (C-c C-c). Vim-Slime should prompt you for Tmux's socket and target pane. I found Tmux's socket with: echo $TMUX | cut -f1 -d','.

  • Alternatively, you can use :SlimeConfig.

  • Now it's working!

Solution 2:

It looks like vim-slime is the way to go.

But updating this in-case it is useful for others.

You could make a mapping as follows. The change from -t + to -t .+ should cause tmux to paste to an alternate pane

vnoremap <leader>tp :call system('tmux send-keys -t .+ -l ' . shellescape(join([getline("."), "\n"])) )<CR>

Reference: Send literal string from python-vim script to a tmux pane

Post a Comment for "Key Bindings To Send Lines Of Test Code With Tmux+vim?"