Quick-and-dirty “edit text in vim” Mac service

Today I wanted to edit a big chunk of text (the source of a wiki page) in a browser textarea, and remembered that I used to have an app that let me open any text in vim, then paste the result back where it came from. Eventually I found the app I was thinking of – QuickCursor – but it turns out it’s no longer available.

Coincidentally I was looking into how to do something else tonight, and the answer was to create a service that ran an AppleScript, and it occurred to me that I could probably make a basic “edit in vim” service fairly easily. Turns out I was right…

Open the “Automator” app, and create a new service. Add a shell script action, and paste in the following script (this assumes you’ve installed the mvim script that comes with MacVim):

filename=`mktemp ~/.edit-in-vim-XXXX`
cat > $filename
/usr/local/bin/mvim -f $filename
cat $filename
rm $filename

Creating a service in Automator

Select “Output replaces selected text” in Automator, save the service, and you’re done. Just select some text (it doesn’t select-all for you like QuickCursor did), right-click and run your new service. You can also assign a keyboard shortcut in System Preferences:

Setting a keyboard shortcut


Upgrading to Snow Leopard

A quick list of things I had to sort out after upgrading to Mac OS X 10.6 Snow Leopard:

Developer Tools

Dont’ forget to run the XCode installer on the Snow Leopard DVD, otherwise you’ll have trouble getting stuff to compile, even if you don’t use XCode. You’ll also have to download and install the iPhone SDK separately if you need it (and possibly even if you don’t – I installed it anyway, just in case).

Ruby and RubyGems

I had both of these installed from source, and although most things seemed to work OK, I couldn’t get Passenger to work at all until I reinstalled them. Instructions for installing are available on HiveLogic – this will overwrite any existing versions, assuming they’re in /usr/local (the system version of Ruby isn’t touched).

Before installing rubygems I removed all my installed gems (gem list|awk '{print $1}'|xargs sudo gem unin -a – there’s probably an easier way), then I reinstalled the ones I needed afterwards.


Although I mostly use Postgres, I reinstalled MySQL following the instructions on the Norbauer blog.


Apparently you can rebuild your ports by just running sudo port upgrade --force installed, but by the time I came across that I’d already trashed and reinstalled as recommended on the link above.

For some reason the MacPorts installer hung while running the postinstall scripts, but after force-quitting the installer then running sudo port sync everything seemed fine.

I added +svn to the arguments for installing git-core (as if it didn’t have enough dependencies to build already!), and also installed postgresql84-server and imagemagick.

Apache and Passenger

I tried a whole bunch of stuff to get Passenger running, but it turned out in the end that rebuilding Ruby was the answer (see above). Once I’d done that, it was a simple case of installing the passenger gem and running sudo passenger-install-apache2-module to install the module.


The standard version of MacVim mostly works under 10.6, but there’s a custom-built binary that seems much more stable and a bit snappier.

Reader Notifier

The release version of Reader Notifier doesn’t work on 10.6, but for now there’s a patched version.

Safari Plugins

ClickToFlash needs to be upgraded to 1.5fc2.

DeliciousSafari hasn’t been updated for 64-bit Safari yet, but as a workaround you can force Safari to run in 32-bit mode. Do a ‘get info’ on the Safari app (in the Applications folder), and tick ‘Open in 32-bit mode’.

iStat Menus

Turns out I was using an old version (1.3) of iStat Menus, which doesn’t work in 10.6 (I noticed the missing menu when I went to check how high all the port install shenanigans were pushing the CPU temperatures). Upgrading to 2.0 sorted it out.


Again, I was using an old version of this iPhoto exporter, but £6.90 and an upgrade to 3.0.2 later and everything was working again.

Remapping caps lock to escape

Not strictly 10.6-specific, but this was something I’d been meaning to get round to since switching back to vim. I was already to start installing input manager hacks until I stumbled across a blog post somewhere mentioning that it is already configurable (and has been for a while). Just open the keyboard preferences, hit ‘Modifier Keys…’ and change the action.