2012-04-11 15:05:08 +00:00
|
|
|
*vimux.txt* easily interact with tmux
|
|
|
|
|
|
|
|
Vimux
|
|
|
|
effortless vim and tmux interaction
|
|
|
|
|
|
|
|
==============================================================================
|
2012-05-31 16:45:27 +00:00
|
|
|
CONTENTS *vimux-contents*
|
|
|
|
|
|
|
|
1. About............................ |VimuxAbout|
|
|
|
|
2. Usage ........................... |VimuxUsage|
|
2012-06-08 15:13:57 +00:00
|
|
|
2.1 .............................. |VimuxPromptCommand|
|
|
|
|
2.2 .............................. |VimuxRunLastCommand|
|
|
|
|
2.3 .............................. |VimuxInspectRunner|
|
|
|
|
2.4 .............................. |VimuxCloseRunner|
|
|
|
|
2.5 .............................. |VimuxClosePanes|
|
|
|
|
2.6 .............................. |VimuxInterruptRunner|
|
2012-06-15 18:06:38 +00:00
|
|
|
2.7 .............................. |VimuxClearRunnerHistory|
|
2012-05-31 16:45:27 +00:00
|
|
|
3. Misc ............................ |VimuxMisc|
|
|
|
|
3.1 Example Keybinding............ |VimuxExampleKeybinding|
|
|
|
|
3.2 Tslime Replacement............ |VimuxTslimeReplacement|
|
|
|
|
4. Configuration ................... |VimuxConfiguration|
|
2012-04-11 15:05:08 +00:00
|
|
|
|
|
|
|
|
|
|
|
==============================================================================
|
2012-05-31 16:45:27 +00:00
|
|
|
ABOUT (1) *VimuxAbout*
|
|
|
|
|
|
|
|
Vimux -- Easily interact with tmux from vim.
|
|
|
|
|
|
|
|
What inspired me to write vimux was tslime.vim [1], a plugin that lets you
|
|
|
|
send input to tmux. While tslime.vim works well, I felt it wasn't optimized
|
|
|
|
for my primary use case which was having a smaller tmux pane that I would use
|
|
|
|
to run tests or play with a REPL.
|
|
|
|
|
|
|
|
My goal with vimux is to make interacting with tmux from vim effortless. By
|
2012-06-08 15:13:57 +00:00
|
|
|
default when you call `VimuxRunCommand` vimux will create a 20% tall
|
2012-05-31 16:45:27 +00:00
|
|
|
horizontal pane under your current tmux pane and execute a command in it
|
|
|
|
without losing focus of vim. Once that pane exists whenever you call
|
2012-06-08 15:13:57 +00:00
|
|
|
`VimuxRunCommand` again the command will be executed in that pane. As I was
|
2012-05-31 16:45:27 +00:00
|
|
|
using vimux myself I wanted to rerun commands over and over. An example of
|
|
|
|
this was running the current file through rspec. Rather than typing that over
|
2012-06-08 15:13:57 +00:00
|
|
|
and over I wrote `VimuxRunLastCommand` that will execute the last command
|
|
|
|
you called with `VimuxRunCommand`.
|
2012-05-31 16:45:27 +00:00
|
|
|
|
|
|
|
Other auxiliary functions and the ones I talked about above can be found
|
|
|
|
bellow with a full description and example key binds for your vimrc.
|
|
|
|
|
|
|
|
[1] https://github.com/kikijump/tslime.vim
|
|
|
|
|
|
|
|
|
|
|
|
==============================================================================
|
|
|
|
USAGE (2) *VimuxUsage*
|
2012-04-11 15:05:08 +00:00
|
|
|
|
2012-06-08 15:13:57 +00:00
|
|
|
The function VimuxRunCommand(command) is the core of Vimux. It will
|
2012-04-11 15:05:08 +00:00
|
|
|
create a split pane in the current window and run the passed command in it.
|
2012-06-08 15:16:01 +00:00
|
|
|
>
|
2012-06-08 15:13:57 +00:00
|
|
|
:call VimuxRunCommand("ls")
|
2012-06-08 15:16:01 +00:00
|
|
|
<
|
2012-04-11 15:05:08 +00:00
|
|
|
This will run the command in a split pane without losing focus of vim. If the
|
|
|
|
command takes a long time to return you can continue to use vim while the
|
2012-05-31 16:45:27 +00:00
|
|
|
process finishes and will see the output in the pane when it's finished.
|
|
|
|
|
2012-06-08 15:13:57 +00:00
|
|
|
Furthermore there are several handy commands all starting with 'Vimux':
|
|
|
|
- |VimuxRunCommand|
|
|
|
|
- |VimuxRunLastCommand|
|
|
|
|
- |VimuxCloseRunner|
|
|
|
|
- |VimuxClosePanes|
|
|
|
|
- |VimuxCloseWindows|
|
|
|
|
- |VimuxInspectRunner|
|
|
|
|
- |VimuxInterruptRunner|
|
|
|
|
- |VimuxPromptCommand|
|
2012-06-15 18:06:38 +00:00
|
|
|
- |VimuxClearRunnerHistory|
|
2012-05-31 16:45:27 +00:00
|
|
|
|
2012-06-08 15:13:57 +00:00
|
|
|
|
|
|
|
Note:
|
|
|
|
Earlier the all commands had different names. There are still aliases for
|
|
|
|
convenience. Please chang your configuration according to the new naming
|
|
|
|
conventions!
|
|
|
|
|
|
|
|
The DEPRECATED commands:
|
2012-05-31 16:45:27 +00:00
|
|
|
- |PromptVimTmuxCommand|
|
|
|
|
- |RunLastVimTmuxCommand|
|
|
|
|
- |InspectVimTmuxRunner|
|
|
|
|
- |CloseVimTmuxRunner|
|
|
|
|
- |CloseVimTmuxPanes|
|
|
|
|
- |InterruptVimTmuxRunner|
|
|
|
|
|
|
|
|
------------------------------------------------------------------------------
|
|
|
|
*RunVimTmuxCommand*
|
2012-06-08 15:13:57 +00:00
|
|
|
*VimuxRunCommand*
|
|
|
|
VimuxRunCommand~
|
2012-05-31 16:45:27 +00:00
|
|
|
|
|
|
|
Run a system command in a small horizontal split bellow
|
|
|
|
the current pane vim is in. You can optionally pass a second argument to stop
|
|
|
|
vimux from automatically sending a return after the command.
|
|
|
|
>
|
|
|
|
" Run the current file with rspec
|
2012-06-08 15:13:57 +00:00
|
|
|
map <Leader>rb :call VimuxRunCommand("clear; rspec " . bufname("%"))<CR>
|
2012-05-31 16:45:27 +00:00
|
|
|
" Run command without sending sending a return
|
2012-06-08 15:13:57 +00:00
|
|
|
map <Leader>rq :call VimuxRunCommand("clear; rspec " . bufname("%"), 0)<CR>
|
2012-05-31 16:45:27 +00:00
|
|
|
<
|
|
|
|
|
|
|
|
------------------------------------------------------------------------------
|
|
|
|
*PromptVimTmuxCommand*
|
2012-06-08 15:13:57 +00:00
|
|
|
*VimuxPromptCommand*
|
|
|
|
VimuxPromptCommand~
|
2012-05-31 16:45:27 +00:00
|
|
|
|
|
|
|
Prompt for a command and run it in a small horizontal split bellow the current
|
|
|
|
pane.
|
|
|
|
>
|
|
|
|
" Prompt for a command to run map
|
2012-06-15 18:06:38 +00:00
|
|
|
<Leader>vp :VimuxPromptCommand<CR>
|
2012-05-31 16:45:27 +00:00
|
|
|
<
|
|
|
|
|
|
|
|
------------------------------------------------------------------------------
|
|
|
|
*RunLastVimTmuxCommand*
|
2012-06-08 15:13:57 +00:00
|
|
|
*VimuxRunLastCommand*
|
|
|
|
VimuxRunLastCommand~
|
2012-05-31 16:45:27 +00:00
|
|
|
|
2012-06-08 15:13:57 +00:00
|
|
|
Run the last command executed by `VimuxRunCommand`
|
2012-05-31 16:45:27 +00:00
|
|
|
>
|
2012-06-08 15:13:57 +00:00
|
|
|
" Run last command executed by VimuxRunCommand
|
2012-06-15 18:06:38 +00:00
|
|
|
map <Leader>vl :VimuxRunLastCommand<CR>
|
2012-05-31 16:45:27 +00:00
|
|
|
<
|
|
|
|
|
|
|
|
------------------------------------------------------------------------------
|
|
|
|
*InspectVimTmuxRunner*
|
2012-06-08 15:13:57 +00:00
|
|
|
*VimuxInspectRunner*
|
|
|
|
VimuxInspectRunner~
|
2012-05-31 16:45:27 +00:00
|
|
|
|
2012-06-08 15:13:57 +00:00
|
|
|
Move into the tmux runner pane created by `VimuxRunCommand` and enter copy
|
2012-05-31 16:45:27 +00:00
|
|
|
pmode (scroll mode).
|
|
|
|
>
|
|
|
|
" Inspect runner pane map
|
2012-06-15 18:06:38 +00:00
|
|
|
<Leader>vi :VimuxInspectRunner<CR>
|
2012-05-31 16:45:27 +00:00
|
|
|
<
|
|
|
|
|
|
|
|
------------------------------------------------------------------------------
|
|
|
|
*CloseVimTmuxRunner*
|
2012-06-08 15:13:57 +00:00
|
|
|
*VimuxCloseRunner*
|
|
|
|
VimuxCloseRunner~
|
2012-05-31 16:45:27 +00:00
|
|
|
|
2012-06-08 15:13:57 +00:00
|
|
|
Close the tmux runner created by `VimuxRunCommand`
|
2012-05-31 16:45:27 +00:00
|
|
|
>
|
2012-06-08 15:13:57 +00:00
|
|
|
" Close vim tmux runner opened by VimuxRunCommand
|
2012-06-15 18:06:38 +00:00
|
|
|
map <Leader>vq :VimuxCloseRunner<CR>
|
2012-05-31 16:45:27 +00:00
|
|
|
<
|
|
|
|
|
|
|
|
------------------------------------------------------------------------------
|
|
|
|
*CloseVimTmuxPanes*
|
2012-06-08 15:13:57 +00:00
|
|
|
*VimuxClosePanes*
|
|
|
|
VimuxClosePanes~
|
2012-05-31 16:45:27 +00:00
|
|
|
|
|
|
|
Close all other tmux panes in the current window.
|
|
|
|
>
|
|
|
|
" Close all other tmux panes in current window
|
2012-06-15 18:06:38 +00:00
|
|
|
map <Leader>vx :VimuxClosePanes<CR>
|
2012-05-31 16:45:27 +00:00
|
|
|
>
|
|
|
|
|
|
|
|
------------------------------------------------------------------------------
|
|
|
|
*InterruptVimTmuxRunner*
|
2012-06-08 15:13:57 +00:00
|
|
|
*VimuxInterruptRunner*
|
|
|
|
VimuxInterruptRunner~
|
2012-05-31 16:45:27 +00:00
|
|
|
|
|
|
|
Interrupt any command that is running inside the
|
|
|
|
runner pane.
|
|
|
|
>
|
|
|
|
" Interrupt any command running in the runner pane map
|
2012-06-15 18:06:38 +00:00
|
|
|
<Leader>vs :VimuxInterruptRunner<CR>
|
|
|
|
<
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
------------------------------------------------------------------------------
|
|
|
|
*VimuxClearRunnerHistory*
|
|
|
|
VimuxClearRunnerHistory~
|
|
|
|
|
|
|
|
Clear ths tmux history of the runner pane for when
|
|
|
|
you enter tmux scroll mode inside the runner pane.
|
|
|
|
>
|
|
|
|
" Clear the tmux history of the runner pane
|
|
|
|
<Leader>vc :VimuxClearRunnerHistory<CR>
|
2012-05-31 16:45:27 +00:00
|
|
|
<
|
|
|
|
|
2012-04-11 15:05:08 +00:00
|
|
|
|
|
|
|
==============================================================================
|
2012-05-31 16:45:27 +00:00
|
|
|
MISC (3) *VimuxMisc*
|
|
|
|
|
|
|
|
------------------------------------------------------------------------------
|
|
|
|
*VimuxExampleKeybinding*
|
|
|
|
Full Keybind Example~
|
2012-04-11 15:05:08 +00:00
|
|
|
|
2012-05-31 16:45:27 +00:00
|
|
|
>
|
|
|
|
" Run the current file with rspec
|
2012-06-08 15:13:57 +00:00
|
|
|
map <Leader>rb :call VimuxRunCommand("clear; rspec " . bufname("%"))<CR>
|
2012-05-31 16:45:27 +00:00
|
|
|
|
|
|
|
" Prompt for a command to run
|
2012-06-08 15:13:57 +00:00
|
|
|
map <Leader>rp :VimuxPromptCommand<CR>
|
2012-05-31 16:45:27 +00:00
|
|
|
|
2012-06-08 15:13:57 +00:00
|
|
|
" Run last command executed by VimuxRunCommand
|
|
|
|
map <Leader>rl :VimuxRunLastCommand<CR>
|
2012-05-31 16:45:27 +00:00
|
|
|
|
|
|
|
" Inspect runner pane
|
2012-06-08 15:13:57 +00:00
|
|
|
map <Leader>ri :VimuxInspectRunner<CR>
|
2012-05-31 16:45:27 +00:00
|
|
|
|
|
|
|
" Close all other tmux panes in current window
|
2012-06-08 15:13:57 +00:00
|
|
|
map <Leader>rx :VimuxClosePanes<CR>
|
2012-05-31 16:45:27 +00:00
|
|
|
|
2012-06-08 15:13:57 +00:00
|
|
|
" Close vim tmux runner opened by VimuxRunCommand
|
|
|
|
map <Leader>rq :VimuxCloseRunner<CR>
|
2012-05-31 16:45:27 +00:00
|
|
|
|
|
|
|
" Interrupt any command running in the runner pane
|
2012-06-08 15:13:57 +00:00
|
|
|
map <Leader>rs :VimuxInterruptRunner<CR>
|
2012-05-31 16:45:27 +00:00
|
|
|
>
|
2012-04-11 15:05:08 +00:00
|
|
|
|
|
|
|
------------------------------------------------------------------------------
|
2012-05-31 16:45:27 +00:00
|
|
|
*VimuxTslimeReplacement*
|
|
|
|
Vimux as tslime replacement~
|
|
|
|
|
|
|
|
Here is how to use vimux to send code to a REPL. This is similar to tslime.
|
|
|
|
First, add some helpful mappings.
|
|
|
|
|
|
|
|
>
|
|
|
|
" Prompt for a command to run
|
2012-06-08 15:13:57 +00:00
|
|
|
map <LocalLeader>vp :VimuxPromptCommand<CR>
|
2012-05-31 16:45:27 +00:00
|
|
|
|
|
|
|
" If text is selected, save it in the v buffer and send that buffer it to tmux
|
2012-06-08 15:13:57 +00:00
|
|
|
vmap <LocalLeader>vs "vy :call VimuxRunCommand(@v . "\n", 0)<CR>
|
2012-05-31 16:45:27 +00:00
|
|
|
|
|
|
|
" Select current paragraph and send it to tmux
|
|
|
|
nmap <LocalLeader>vs vip<LocalLeader>vs<CR>
|
|
|
|
<
|
|
|
|
|
|
|
|
Now, open a clojure file. Let's say your leader is backslash (\). Type \vp,
|
|
|
|
and then type lein repl at the prompt. This opens a tmux split running a REPL.
|
|
|
|
Then, select text or put the cursor on a function and type \vs. This will send
|
2012-06-08 15:13:57 +00:00
|
|
|
it to the REPL and evaluate it. The reason we pass `0` to `VimuxRunCommand`
|
2012-05-31 16:45:27 +00:00
|
|
|
is to stop the normal return that is sent to the runner pane and use our own
|
|
|
|
new line so the clojure REPL will evaluate the selected text without adding an
|
|
|
|
extra return. Thanks to @trptcolin for discovering this issue.
|
|
|
|
|
|
|
|
|
|
|
|
==============================================================================
|
|
|
|
CONFIGURATION (4) *VimuxConfiguration*
|
|
|
|
|
|
|
|
You can configure Vimux like this:
|
|
|
|
|
|
|
|
------------------------------------------------------------------------------
|
|
|
|
*VimuxConfiguration_height*
|
|
|
|
2.1 g:VimuxHeight~
|
2012-04-11 15:05:08 +00:00
|
|
|
|
|
|
|
The percent of the screen the split pane Vimux will spawn should take up.
|
|
|
|
|
|
|
|
let g:VimuxHeight = "40"
|
|
|
|
|
|
|
|
Default: "20"
|
|
|
|
|
|
|
|
------------------------------------------------------------------------------
|
2012-05-31 16:45:27 +00:00
|
|
|
*VimuxConfiguration_orientation*
|
|
|
|
2.2 g:VimuxOrientation~
|
2012-04-11 15:05:08 +00:00
|
|
|
|
|
|
|
The default orientation of the split tmux pane. This tells tmux to make the
|
|
|
|
pane either vertically or horizontally, which is backward from how Vim handles
|
|
|
|
creating splits.
|
|
|
|
|
|
|
|
let g:VimuxOrientation = "h"
|
|
|
|
|
|
|
|
Options:
|
|
|
|
"v": vertical
|
|
|
|
"h": horizontal
|
|
|
|
|
|
|
|
Default: "v"
|
2012-04-12 10:29:48 +00:00
|
|
|
|
|
|
|
------------------------------------------------------------------------------
|
2012-05-31 16:45:27 +00:00
|
|
|
*VimuxConfiguration_use_nearest_pane*
|
|
|
|
2.3 g:VimuxUseNearestPane~
|
2012-04-12 10:29:48 +00:00
|
|
|
|
|
|
|
Use exising pane (not used by vim) if found instead of running split-window.
|
|
|
|
|
2012-04-14 18:20:45 +00:00
|
|
|
let VimuxUseNearestPane = 1
|
2012-04-12 10:29:48 +00:00
|
|
|
|
|
|
|
Default: 0
|
2012-04-20 21:24:41 +00:00
|
|
|
|
|
|
|
------------------------------------------------------------------------------
|
2012-05-31 16:45:27 +00:00
|
|
|
*VimuxConfiguration_reset_sequence*
|
|
|
|
2.4 g:VimuxResetSequence~
|
2012-04-20 21:24:41 +00:00
|
|
|
|
|
|
|
The keys sent to the runner pane before running a command. By default it sends
|
|
|
|
`q` to make sure the pane is not in scroll-mode and `C-u` to clear the line.
|
|
|
|
|
2012-07-29 12:54:45 +00:00
|
|
|
let VimuxResetSequence = ""
|
2012-04-20 21:24:41 +00:00
|
|
|
|
|
|
|
Default: "q C-u"
|
2012-05-31 16:45:27 +00:00
|
|
|
|
|
|
|
|
|
|
|
==============================================================================
|
|
|
|
vim:tw=78:ts=2:sw=2:expandtab:ft=help:norl:
|