TextEdit is the default text editor in macOS, and it’s just as barebones as the default text editor in Windows, Notepad. Naturally, many Mac users sooner or later look for an alternative, and they often stumble upon Notepad++.
[robg adds: While I could make this script work for files on a one-at-a-time basis, I could not get the Change All solution to work -- regardless of how I specified the app, or set the file's extension, Change All had no effect. Only the selected file was modified to open with vi; a commenter on the queue review site had the same experience. If you know how to resolve that issue, please comment...]
This is because the applet doesn't have a unique bundle identifier or bundle signature ('creator code') by default; when Script Editor saves an Application Bundle (or a PPC-only Application), it uses the dplt
(or aplt
, for applets that don't handle on open
) bundle signature (and does not specify a bundle identifier at all). dplt
and aplt
are shared with every other applet/droplet on your Mac—not useful for trying to set a default binding to a specific app….
First, make sure you're saving the script as an 'Application Bundle' in Script Editor, not an 'Application', because you can't fix this problem with an old-school 'Application' (and because Applications are PPC-only; who wants to start Rosetta to launch vi on an Intel Mac?!).
The easiest way to fix this is to change the bundle signature in your applet's Info.plist
and PkgInfo
files to something unique; I used dpVI
when verifying this. 'Show Package Contents' on your app and open both of those files in a text editor (vi, even!) and find dplt
in each file, replace it with dpVI
, and save. Finally, move the VI.app out of the Applications folder to the Desktop, and then back in to Applications (to get LaunchServices to pick up your Info.plist
changes). The drawback to this change is that every time you open the app in Script Editor to make further changes, you have to dismiss an alert about the app not being scriptable.
You could also (or in addition) add a CFBundleIdentifier
key to the Info.plist, something like:
<key>CFBundleIdentifier</key>
<string>com.macosxhints.vi-app</string>
Simply add that with your favorite text editor (or Property List Editor) among the other CFBundle* keys in your Info.plist