When I double-click a code file in Finder, I want it to open in Vim in a terminal. Not in MacVim. Not in some lesser editor.
The end result: double-clicking a file opens a new iTerm window with the file opened in Vim.
execs Vim (replaces the shell process), the window closes when you quit Vim. This also means you can’t
⌃Z out of the Vim session. Think of it as an editor window, not a full-fledged terminal.
1. Get an
Download TerminalVim.app, unzip it and stick the app in
Or make your own:
- Open Apple’s “Automator” app.
- If you get a file dialog, opt to create a “New Document”.
- Select the “Application” type.
- Search the action list for “Run AppleScript”, double-click that option.
- Change the script to this (hat tip to Rob Peck):
- Save as
2. Tell Finder to use your app
- In Finder, select some file you want to open in Vim, e.g. a
⌘Ito 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.
.rb files in Finder will open in Vim.