2

I'm trying to hook up my Vim so I can send commands to a running IPython instance. There are scripts for this, but they are outdated. I'm trying to write a new one.

My main stumbling block right now is the proper way to make IPython listen to incoming network connections in the background (i.e. a different thread, other solutions are welcome) and executing the received commands in the main thread. Earlier scripts did not execute commands in the main thread and would crash for instance matplotlib regularly.

I see that twisted provides a ThreadedSelectReactor, but I'm at a loss as to how to use it properly with IPython.

Update

A scenario example would be:

2 Windows open, one is a terminal running IPython, one is Vim where you are editing a python script. You select a line in Vim and hit C-Enter, Vim sends the line to the IPython instance, which executes it and prints the result in the IPython terminal, just as if you had copy/pasted the line over myself.

(Matlab users know how useful this functionality can be.)

3
  • What are you sending over the network? Text commands? Can you give a specific example of what you're trying to accomplish with the socket? Commented Dec 9, 2011 at 11:51
  • I've added an example scenario. Commented Dec 9, 2011 at 13:01
  • This question has a misleading title now, as the original question is now replaced by an answer to what you call 'other solutions'. Would you mind to retitle it? Commented Oct 3, 2020 at 23:32

2 Answers 2

1

Paul Ivanov did this a few months ago, using IPython's zmq interface. It's called vim-ipython.

Sign up to request clarification or add additional context in comments.

1 Comment

Exactly what I was looking for. This means I don't have to write it myself!
1

I get the impression that IPython is or has moved to using zmq as messaging protocol. Atleast when I am running 0.11 version zmq support is available.

Using zmq(zero mq) the whole message passing problem is very much reduced to get your Vim instance to communicate over zmq which as far as I know should not be that hard (zmq is ported to a wide variety of platforms).

Look into this blog: http://ipythonzmq.blogspot.com/ and of course: http://www.zeromq.org/

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.