Skip to content

Commit c1c4e3a

Browse files
committed
Send more keys with VimuxSendKeys
This patch addresses issue #44, where @gberenfield says: > I can't seem to paste in around 30-40 lines of code into my vimux repl. > Anything less works fine. I write the selected text to a temporary file, read the file with tmux, and paste the contents into the appropriate window. Caveats: - When sending the text, vim prompts you with a `more` screen in which you must press Enter repeatedly to scroll to the end. The text is actually sent after you're done mashing the Enter button. I haven't found a way around this -- I'm new to Vimscript.
1 parent fbb873a commit c1c4e3a

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

plugin/vimux.vim

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,25 @@ function! VimuxRunCommand(command, ...)
4444
endfunction
4545

4646
function! VimuxSendText(text)
47-
call VimuxSendKeys('"'.escape(a:text, '"').'"')
47+
" Escape double quotes "
48+
"call VimuxSendKeys('"'.escape(a:text, '"').'"')
49+
" Don't escape, just send it along.
50+
call VimuxSendKeys(a:text)
4851
endfunction
4952

5053
function! VimuxSendKeys(keys)
5154
if exists("g:VimuxRunnerIndex")
52-
call system("tmux send-keys -t ".g:VimuxRunnerIndex." ".a:keys)
55+
" This is limited to ~30 lines or so, and I want to send more!
56+
" call system("tmux send-keys -t ".g:VimuxRunnerIndex." ".a:keys)
57+
" HACK: Write to a temporary file.
58+
redir! > /tmp/VimuxSendKeys
59+
echo a:keys
60+
redir END
61+
" Load from the temporary file.
62+
" Unfortunately, You have to press Enter to get back to editing.
63+
call system("tmux load-buffer /tmp/VimuxSendKeys; tmux paste-buffer -t ".g:VimuxRunnerIndex)
64+
" This causes vim to hang. :(
65+
" call system("tmux load-buffer -; tmux paste-buffer -t ".g:VimuxRunnerIndex, a:keys)
5366
else
5467
echo "No vimux runner pane/window. Create one with VimuxOpenRunner"
5568
endif

0 commit comments

Comments
 (0)