詩と創作・思索のひろば

ドキドキギュンギュンダイアリーです!!!

Fork me on GitHub

My Vim settings for tmux

" .vimrc
command! -nargs=* -complete=shellcmd TmuxSplitRun
            \ let _cmd = len(<q-args>) ? shellescape(substitute(<q-args> . '; read' , '%', expand('%'), '')) : '' |
            \ let tmux_cmd = printf('tmux if-shell "tmux select-pane -t.1" "send-keys ^C" \; if-shell "tmux respawn-pane -t.1 %s" "select-window" "split-window -d -v -p 30 %s"', _cmd, _cmd) |
            \ call system(tmux_cmd)

Provides command such as:

:TmuxSplitRun perl %

which splits tmux window horizontally and evaluate current file in another pane, could be alternative for :!. After the command finishes, hit enter to close the pane.

f:id:motemen:20130911193746g:plain

Or without arguments:

:TmuxSplitRun

Starts a new shell.

And with this mapping:

nnoremap <C-J> :
cnoremap <expr> <C-J>  getcmdline() == '' ? '!' : getcmdline() == '!' ? "\<C-U>TmuxSplitRun " : "\<CR>"

hitting C-J successively changes cmdline, : to :! to :TmuxSplitRun, one after one. On last hit, :TmuxSplitRun is executed and you will get a new shell pane.

はてなで一緒に働きませんか?