I’ve just found IPython and I can report that I’m in deep love. And the affection was immediate. I think this affair will turn into something lasting, like the one I have with screen. Ipython and screen happen to be the best of friends too so it’s a triangular drama. Purely platonic, mind you.
The reason IPython hits the soft spots with me are very much because I generally like command prompts, and especially *nix-inspired prompts with inspiration from ksh, csh (yes, chs is a monster, but as a prompt it sport lots of really good features), bash and zsh. And IPython does sure feel like home for a *nix prompt rider. Mixing the system shell and python is also a really good idea. Plus, of course, IPython helps a lot when solving the Python Challenge riddles. Invaluable even.
Now, I love Vim too. Since I learnt vi back in the days there’s no turning back. And I’m on Mac when I have a choice. Now I’d like to glue together my IPython + MacVim workflow. What I’ve done so far is that I start Ipython using:
ipython -e 'open -a MacVim'
Thus when I edit from IPython it starts MacVim with the file/module loaded. Could look a bit like so:
In [4]: %run foo #This also 'imports' foo anew hello world In [5]: edit foo Editing... done. Executing edited code... #This happens immediately hello world In [6]: %run foo hello SO World
OK. I think this can be improved. Maybe there’s a way to tie IPython into MacVim too? Please share your experiences. Of course if you use TextMate or some other fav editor I’m interested too. Maybe some of the lessons are general.
I use Linux, but I believe this tip can be used in OS X too. I use GNU Screen to send IPython commands from Vim as recommended by this tip. This is how I do it:
First, you should open a terminal and start a screen session called ‘ipython’ or whatever you want, and then start IPython:
Then you should put this in your .vimrc:
Then when you hit F5, it will tell Screen to execute the command ‘%run file’ inside the ‘ipython’ created previously, where file is your current buffer in Vim.
You can tweak this to execute the command you want inside IPython from Vim. For example I use this:
This executes %reset (answering yes to the prompt), then change to the directory where the current buffer in vim is located and then %run the file. This is specially useful if you have the %pdb active in IPython.
Don’t forget that you need an active Screen session called ‘ipython’ with IPython running inside.
If you like Emacs. There is good support for IPython.