home, home on the web
where the links and the hypertexts play

'Open With' Vim from MacOS Finder

Published 2020-05-08

I use Vim on the command line for almost all my text editing. Occasionally I find myself browsing around in Finder and wishing I could right-click a file and open it in Vim on the terminal.

I found the following solution. First, follow the instructions here to create a “TerminalVim.app” application. At this point, we’re 90% of the way there. You should be able to right-click any file, click Open With, choose Other, and browse to your new TerminalVim.app.

However, that’s still more steps than we would like. In order to add TerminalVim to your Open With list:

  1. Right-click your new TerminalVim.app, and click Show Package Contents.
  2. Open Contents/Info.plist
  3. Find the line <key>CFBundleTypeExtensions</key> and add new array items for each file type you want to associate with your app, as shown:
  1. Run /System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/LaunchServices.framework/Versions/A/Support/lsregister -f /Applications/TerminalVim.app
  2. Run killall Finder
  3. You should now be able to right-click one of your chosen file types and open it in Vim!