Skip to content

Send command from vim to a running tmux session

Notifications You must be signed in to change notification settings

antislava/tslime.vim

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

73 Commits
 
 
 
 
 
 

Repository files navigation

tslime.vim

Fork notes

Goal: Customising the plugin to Haskell repl (ghci)

Summary of additions:

  • Proper backtick escaping
  • Versions of the main tmux-send functions surrounding the text argument with :{ and :}

Example vim shortcut definitions in vim.rc:

vmap <silent> <Leader>rs <Plug>SendSelectionToTmux
nmap <silent> <Leader>rs <Plug>NormalModeSendToTmux

vmap <silent> <Leader>rt <Plug>SendHaskellToTmux
nmap <silent> <Leader>rt <Plug>NormalModeHaskellToTmux

nmap <silent> <Leader>rv <Plug>SetTmuxVars

This is a simple vim script to send portion of text from a vim buffer to a running tmux session.

It is based on slime.vim http://technotales.wordpress.com/2007/10/03/like-slime-for-vim/, but use tmux instead of screen. However, compared to tmux, screen doesn't have the notion of panes. So, the script was adapted to take panes into account.

Note: If you use version of tmux earlier than 1.3, you should use the stable branch. The version available in that branch isn't aware of panes so it will paste to pane 0 of the window.

Settings

You can tell tslime.vim to use the current session and current window, this let's you avoid specifying this on every upstart of vim.

let g:tslime_always_current_session = 1
let g:tslime_always_current_window = 1

These are disabled by default, meaning you will have the ability to choose from every session/window/pane combination.

Setting Keybindings

In this fork of tslime.vim, keybindings are not set automatically for you. Instead, you can map whatever you'd like to one of the plugin-specific bindings in your .vimrc file.

To get the old defaults, put the following in your .vimrc:

vmap <C-c><C-c> <Plug>SendSelectionToTmux
nmap <C-c><C-c> <Plug>NormalModeSendToTmux
nmap <C-c>r <Plug>SetTmuxVars

To send a selection in visual mode to vim, set the following in your .vimrc:

vmap <your_key_combo> <Plug>SendSelectionToTmux

To grab the current method that a cursor is in normal mode, set the following:

nmap <your_key_combo> <Plug>NormalModeSendToTmux

Use the following to reset the session, window, and pane info:

nmap <your_key_combo> <Plug>SetTmuxVars

Have a command you run frequently, use this:

nmap <your_key_combo> :Tmux <your_command><CR>

More info about the <Plug> and other mapping syntax can be found here.

About

Send command from vim to a running tmux session

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Vim Script 100.0%