SLIME-like support for running vim with iTerm2
For the video-inclined watch it here.
It lets you send commands from Vim to an iTerm2 session. This is handy if you need to run a command repeatedly (like a test) and want to see the output. This is especially nice in text-mode Vim, but it works fine from MacVim's GUI too.
It works by using AppleScript to switch to the next iTerm2 Pane (using
Cmd+]), writing the appropriate text then switching back (using
At the moment rather than support all the possible testing methods I have
<leader>ft try to run
script/test against the current file and
<leader>fT pass the current file as
path:line_number. I'll include a contrib directory with various testing tools in the near future but for now a simple
script/test for Rails would be:
#!/bin/sh ruby -Itest "$@"
Of course this wouldn't support focused unit testing. More on that to come soon.
If you're using rspec, focused testing works just fine, like so:
#!/bin/sh rspec "$@"
ISlime2 echo hi mom- runs "echo hi mom"
<leader>ff- re-runs the last run command
<leader>fp- equivalent to hitting up then enter in the terminal
<leader>cc- sends the current paragraph (using
vip) or selection to the terminal
<leader>cf- sends the whole file to the terminal
script/deliverwhich I use to merge to master and deploy to staging
Are welcome! Pull request to your heart's content. I'd love to turn this into a general purpose development tool.
Copyright © Mat Schaffer. Distributed under the same terms as Vim itself. See :help license.
- Tim Pope, for vim-fugitive which was a nice reference for how to run stuff from Vim script.
- Jonathan Palardy, for vim-slime, the original inspiration for this plugin.
- Troy Bollinger and Patrick Bacon for writing the AppleScript that helped me write my own.
- George Nachman for writing iTerm2, easily the most bad-ass terminal emulator I know of.
- Lar Van Der Jagt, Shay Arnett, Josh Davey and Robert Pitts for the tweets that got me going on this