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