- Open Automator
- Choose "New Document"
- Locate "Run AppleScript" and double-click it
- Paste the Applescript code into the box
- Save as
/Applications/TerminalVim.app
- In Finder, select some file you want to open in Vim, e.g. a .rb file.
- Hit
⌘I
to open the “Get Info” window. - Under “Open with:”, choose
TerminalVim.app
. You may need to select “Other…” and then browse. - Hit the “Change All…” button and confirm.
Now all .rb files in Finder will open in Vim.
Works like a charm. Being on a mac with all sorts of weird characters in filenames you might want to change
"set filename to POSIX path of input"
to
"set filename to quoted form of POSIX path of input"