A while ago I wrote about executing Ruby code in Vim. That was cool, but I didn’t like only having that functionality available to Vim.
Then I found the Pipe2Eval Vim plugin. Pipe2Eval works similarly but has much improved support, including Ruby, JS, Python, PHP, CoffeeScript and so on.
Installation is straightforward and unlike the other solution there’s no gems to install.
By default, Pipe2Eval tries to store the temporary files it needs to /dev/shm/. On Mac OS X however, the /dev/ folder is well locked down permissions wise, so what I did was create a new folder, and export the environment variable Pipe2Eval looks for:
mkdir /tmp/shm $ export PIP2EVAL_TMP_FILE_PATH=/tmp/shm
You may wish to add that second line to your zshrc/bashrc or similar.
Once that’s done, the plugin should work just fine. Highlight some lines you want to execute with Visual mode, and then hit the spacebar.
comments powered by Disqus