Skip to content

Commit

Permalink
Send more keys with VimuxSendKeys
Browse files Browse the repository at this point in the history
This patch addresses issue preservim#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.
  • Loading branch information
slowkow committed May 23, 2014
1 parent fbb873a commit c1c4e3a
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions plugin/vimux.vim
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,25 @@ function! VimuxRunCommand(command, ...)
endfunction

function! VimuxSendText(text)
call VimuxSendKeys('"'.escape(a:text, '"').'"')
" Escape double quotes "
"call VimuxSendKeys('"'.escape(a:text, '"').'"')
" Don't escape, just send it along.
call VimuxSendKeys(a:text)
endfunction

function! VimuxSendKeys(keys)
if exists("g:VimuxRunnerIndex")
call system("tmux send-keys -t ".g:VimuxRunnerIndex." ".a:keys)
" This is limited to ~30 lines or so, and I want to send more!
" call system("tmux send-keys -t ".g:VimuxRunnerIndex." ".a:keys)
" HACK: Write to a temporary file.
redir! > /tmp/VimuxSendKeys
echo a:keys
redir END
" Load from the temporary file.
" Unfortunately, You have to press Enter to get back to editing.
call system("tmux load-buffer /tmp/VimuxSendKeys; tmux paste-buffer -t ".g:VimuxRunnerIndex)
" This causes vim to hang. :(
" call system("tmux load-buffer -; tmux paste-buffer -t ".g:VimuxRunnerIndex, a:keys)
else
echo "No vimux runner pane/window. Create one with VimuxOpenRunner"
endif
Expand Down

0 comments on commit c1c4e3a

Please sign in to comment.