christoomey / vim-tmux-runner

Vim and tmux, sittin' in a tree...
MIT License
291 stars 37 forks source link

Add operator for sending text #61

Open christoomey opened 8 years ago

christoomey commented 8 years ago

Rather than requiring a full line or visually selected range, go big and make an custom operator for this. Then it would be possible to send portions of lines, paragraphs, etc. Embrace the Vim!

ericboehs commented 6 years ago

I'd love this! Commonly I'm debugging code and I'd like to see what a particular variable evaluates to in my pry session. What I have to do now is yank the text and copy it to a new line. For example, if I want to know what's on_the_stove:

binding.pry
if on_the_stove.include? :teapot
  turn_on_teapot_burner
end

I need to yank the variable to a new line to send it:

binding.pry
on_the_stove # :VtrSendLinesTo
if on_the_stove.include? :teapot
  turn_on_teapot_burner
end
christoomey commented 6 years ago

Yep, I do very similar things all the time. Having a custom operator has been my plan for a while, I've just not found the time / felt the urgency to get it done.

vinodkri commented 6 years ago

Hi Chris,

I was able to get the Vim motion commands working with VTR :)

I have binded "\<leader>sm" as the trigger both in visual and normal modes. Do take a look.

There are minor things to clean-up:

For running python code correctly indentation is critical, so "g:VtrStripLeadingWhitespace" needs to be set to '0' for python programmers. We need to document it.

Prefer to combine VtrSendLinesToRunner with the VtrSendLinesWithMotion if possible. Currently, VtrSendLinesWithMotion does not support range commands. I was unable to figure that out.

I raised the PR, Let me know what you think.

vinodkri commented 6 years ago

Hi Chris,

Updating some of the key usages for reference and future documentation: Below, assume "\<leader>sm" is \<prefix>

  1. \<prefix>w - send's word under the cursor to attached pane.
  2. \<prefix>i( - send's word/words between paranthesis to attached pane. "Ex: (x\<cursor>yz) - xyz is sent"
  3. \<prefix>$ - send's current line from the cursor position to attached pane.
  4. \<Ctrl - v> select 'n' lines, \<prefix> - sends selected lines to attached pane.