20090506

Send text from vim to any REPL

Like I said back in April, I'd been looking for a convenient way to interact with any REPL from vim. Nothing had been satisfactory until I found Mr. Martinez's vicle.vim, which is in turn based on Jonathan Palardy's slime.vim. Thanks to both of them! I really learned a lot. Vicle was a great starting point. However, I wanted a little different behavior from it. It needed modification to play well with GHCi and literate Haskell.

Now I have a decent initial version. I've tried single lines with GHCi, Python, and the shell. I've done blocks in GHCi. All seem to work fine. I guess any REPL works for single lines: Octave, R, maybe an ftp session, etc. Multiple lines with a REPL other than GHCi will require modification of the script. Please try it and let me know if it has problems or if you have any suggestions on how it could be improved. it requires GNU Screen. The biggest problem I know of with it is the 4096 byte limitation mentioned by Mr. Martinez. It would be nice to find a way around that.

Like vicle.vim and slime.vim, you will need GNU Screen. I start it with something like this:
screen -S haskellSession -t haskellSession ghci
Map the commands at the bottom to convenient keys in your .vimrc. I use Enter for :SendtoreplSend and in visual mode also Enter for :SendtoreplSendBlock. For blocks, it's also convenient to do something like map F10 to the command sequence "vip".

Download sendtorepl.vim: http://www.srl.im.dendai.ac.jp/renick/sendtorepl.vim

It's time to get busy using this.

No comments: