preservim / vimux

easily interact with tmux from vim
MIT License
2.19k stars 159 forks source link

How to send text from vim to a tmux pane? #136

Closed gBopHuk closed 7 years ago

gBopHuk commented 8 years ago

I see you removed VimuxSendText. How to send text to a tmux pane at now?

english commented 8 years ago

@gBopHuk VimuxSendText still exists.

There's a section in the documentation explaining how to set up a couple of mappings to use VimuxSendText. I've just pasted the following into my .vimrc and I'm able to send Ruby code from my buffer to a pry session running in a tmux pane:

function! VimuxSlime()
  call VimuxSendText(@v)
  call VimuxSendKeys("Enter")
endfunction

" If text is selected, save it in the v buffer and send that buffer it to tmux
vmap <Leader>vs "vy :call VimuxSlime()<CR>

" Select current paragraph and send it to tmux
nmap <Leader>vs vip<LocalLeader>vs<CR>
dkrieger commented 8 years ago

@gBopHuk or use https://github.com/tpope/vim-tbone (I use both)

timjstewart commented 7 years ago

BTW I found the difference between ipython and python interesting.

After running VimuxRunCommand "ipython", I select the following Python code inside of vim:

def flappy(): num = 1 print(num * num) and then hit vs, I see the following in iPython's shell:

In [20]: def flappy(): ...: num = 1 ...: print(num * num) File "<ipython-input-20-e69ed03d3e2a>", line 3 print(num * num) ^ IndentationError: unexpected indent

It's not obvious but each subsequent line in the ipython REPL has one more level of indent than the last.

This works fine in plain old python's REPL. iPython must be inserting its own indentation. Sounds like I need a custom version of VimuxSlime() for when the target does indentation automatically.

leostera commented 7 years ago

Closing this question as it was answered by @english.