1

Apologies if this has been asked before, but I feel overwhelmed with the Vim docs and I can't seem to figure this out.

I want to map the F5 key in Vim to accomplish the following actions:

  1. Yank text from the visual selection in Vim.

  2. Execute the yanked portion of the text in another GNU Screen session named ipython.

The second portion could be achieved by issuing the following command line argument (via :!), if only I was able to find a way to paste the register content between the double quotes of that line (but I can't figure out how):

map <F5> :!screen -x ipython -X stuff "[REGISTER 0 CONTENT]"<CR><CR>

Any help would be much appreciated!

ib.
  • 27,830
  • 11
  • 80
  • 100
Vincent
  • 15,809
  • 7
  • 37
  • 39
  • 2
    Check out [this previous answer of mine to a similar question](http://stackoverflow.com/questions/7906858/vim-run-selected-code-in-a-persistent-repl-environment/7908050#7908050). – romainl Nov 04 '11 at 20:55
  • Thanks so much for this! slime.vim works exactly as advertised and does precisely what I needed. I upvoted your other answer, but you can repost here if you want me to accept it. – Vincent Nov 05 '11 at 13:53

3 Answers3

2

For the second part, you can use

:execute "!screen -x ipython -X stuff " . shellescape(@0)
Neil
  • 54,642
  • 8
  • 60
  • 72
1

Here I copy my previous answer:

Maybe one of these two plugins is what you need:

Community
  • 1
  • 1
romainl
  • 186,200
  • 21
  • 280
  • 313
1

Given the nature of your question - I encourage you to take a look at vim-ipython. Using this plugin, you can send lines or whole files for IPython to execute, and also get back object introspection and word completions in Vim, like what you get with: object?<enter> and object.<tab> in IPython.

If you follow that github link, there are a few screencasts demonstrating what you can do with it. It requires IPython 0.11 or later, though, with ZeroMQ enabled.

Paul Ivanov
  • 1,984
  • 1
  • 16
  • 14
  • Thanks Paul. I've actually played around with your plugin already and find it excellent. I'm also doing lots of interactive data analysis with R though, so the slime solution is a one-stop shop for me. But vim-ipython will definitely stay on my radar. – Vincent Nov 11 '11 at 03:09