If you’re reading this, then please allow me to welcome you – a fellow person of specific needs and preferences!
It has bothered me several times in the past that I can’t use my text editor of choice everywhere I can edit text. There is an insect brain muscle memory that comes from being a long-time vim user. For example, I regularly find myself resorting to vim commands/shortcuts in places like GMail. I think it’s just my body trying to get me back to using
mutt to read email again. Regardless, this isn’t about email unfortunately.
*.app files as the editor. Since vim is a command-line tool, this doesn’t just work.
I set out today to solve this problem once and for all, and eventually pieced a solution together from bits and pieces I found online. The solution is to use Automator to create an “Application” that runs a shell script that runs an Apple script that activates Terminal.app and tells it to run vim to edit the file in question.
Create a new Application
From the Library, choose “Run Shell Script”.
Ensure you are running
/bin/bashas the shell, and that you have the “Pass input” dropdown set to
- Paste this script code:
osascript <<END tell application "Terminal" activate do script "/usr/bin/vim $@;exit" end tell END
Save this Automator app somewhere.
Now you can tell the application you are using to use this new app as its external editor.
Here is a screenshot of the Automator window where you build the app: