Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

anemo

macrumors newbie
Original poster
Sep 25, 2023
2
1
In MacOS Ventura, how can I configure Sublime Text as the default text editor for all files with MIME type `text/plain`

Please don't suggest using the `Open with` option in the `Get Info` window.
This doesn't work for many of the files I work with daily, like `dotfiles`, files without extensions, etc.

I have to use the `Open with` context menu tens of times every day, and it's so very annoying.

Any help would be much appreciated.
 
I set my more common file types (.txt, .md, a few others) to open with Sublime, but in the end I just resigned myself some time ago to using the context menu or dragging the file onto Sublime in the dock.

I wonder if one could set up some kind of Automator action or script that would take the selected Finder item and pass it on to Sublime, triggered by a key shortcut of some kind. Still more work than double-clicking, but maybe less work than right-clicking :)
 
I'll offer a suggestion.
It may work for you.
Or... it may not.
But... the only way you'll know is if you try it.

There is an old, but still usable (at least up to and including Mojave, which I still use) preference pane called "rcdefaultapp" which is superior to anything else out there.

It's now discontinued by its author but it's still available here:

I suggest you download it and put it into:
(root level) System --> Library --> Extensions.
Then, reboot.

Open system preferences (or settings).
Is the Default Apps extension "there"?

If it isn't, I'm guessing it doesn't work any more.
Just trash it.

If it IS THERE, then I'm going to guess it still works (at least for now).
So, do this next:
Click on the "extensions" pane.
Scroll down (a long way) until you see "text".
Click it and look to the right.

It will show you the default application for "text" files.
You can click on the popup -- do so.
You mentioned the app "Sublime Text" -- is it there?
If so, select it.

If it's NOT there, try the "other" option at the bottom of the popup menu.
It should open a dialog that lets you select any app in your applications folder.
Select Sublime Text and see if that "takes".

Now, close System preferences and try double-clicking on the file in question.
Did this work for you?

Again, you're not going to KNOW, unless you TRY it.

EDIT:
I just tried it for myself.
I downloaded Sublime Text.
Open RCDefault app and set it to be the app to use for file extension "text".
Double-clicked on a text file on my desktop.
It opened into Sublime Text.

So... it seems to work here, using Mojave.
 
I'll offer a suggestion.
It may work for you.
Or... it may not.
But... the only way you'll know is if you try it.

There is an old, but still usable (at least up to and including Mojave, which I still use) preference pane called "rcdefaultapp" which is superior to anything else out there.

It's now discontinued by its author but it's still available here:
Somebody ported it to swift, and has now resumed development on it, so there's hope for new versions. I managed to get it to run on Ventura? Maybe it was Monterey, can't remember for sure.
 
For anyone wanting to open .gitignore and other dot-files with a custom text editor, this is the solution which works for the Finder and the Terminal without installing any third party applications.

1. In the Terminal execute this to set everything to SublimeText 4 in this example:

defaults write com.apple.LaunchServices/com.apple.launchservices.secure LSHandlers -array-add '{LSHandlerContentType=public.data;LSHandlerRoleAll=com.sublimetext.4;}'

2. Then reboot your Mac to apply the changes!

Explained:
  • LSHandlerContentType=public.data selects all files without a file ending like .txt so all the .gitignore and .config files. A file without an ending is interpreted as data on macOS.
  • Use LSHandlerContentType=public.plain-text to select only the .txt files.
  • The LSHandlerRoleAll=com.sublimetext.4sets SublimeText4 as the application to handle those files.
    • If you need the bundle identifier of the text editor of your choice: Go to the .app of your editor select Show Package Contents go to the folder Contents and open the Info.plist. (If you do not have Xcode installed you probably need to install some software to read it.). In the Info.plist find the Bundle identifier key which usually starts with com..
To see what is currently set as defaults execute in the terminal:
open ~/Library/Preferences/com.apple.LaunchServices/com.apple.launchservices.secure.plist (Again you need Xcode or some other tool for .plist files)

(If you made a mistake and want to reset EVERY file ending that you changed delete the com.apple.launchservices.secure.plist and reboot, macOS will recreate this file on reboot but ALL changes you made to ANY file ending will be lost.)

The key misunderstanding in the thread above is that OP wants all public.data files to be changed and all previous solutions focus on the public.plain-text file format. A data file which is opened with textEdit and contains text is still a data file. So you need to tell macOS to change the data files.

This solution also integrates with the normal mechanism of macOS that you also edit it you use `Change all...` in the `Open with` option in the `Get Info` window. You can actually see your changes you made this way in the com.apple.launchservices.secure.plist file.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.