MacOS – Replace TextEdit as the default text editor in MacOS Big Sur

big surmacostext-editor

I just never want TextEdit to be opened, and instead set sublime as the default editor for all plain-text files. So not only files with *.txt extension.

For older versions than Big Sur the following command always has worked for me:

defaults write com.apple.LaunchServices/com.apple.launchservices.secure \
    LSHandlers -array-add \
    '{LSHandlerContentType=public.plain-text;LSHandlerRoleAll=com.sublimetext.3;}'

From this answer: https://apple.stackexchange.com/a/123834/405588

But on Big Sur this doesn't work anymore. Even after restarting MacOS text files still open with TextEdit.

edit: apparently after running the command above double clicking dot files like ~/.bashrc do open in Sublime. But when running open ~/.bashrc from Terminal it still opens the file in TextEdit…

Best Answer

Have you tried SwiftDefaultApps? It's a modern replacement for the old RCDefaults System Preferences pane.

https://github.com/Lord-Kamina/SwiftDefaultApps

Here are two screen shots of SwiftDefaultApps, the first showing Uniform Type Identifiers tab for public.plain.text with Sublime Text 2 set as the Editor, and the second showing the Applications tab and Sublime Text 2 with public.plain.text checked. (This works the same with Sublime Text 3 too.)

With these settings, any plain text file, with or without a .txt extension, will open in Sublime Text when double-clicked in Finder.

SwiftDefaultApps - Uniform Type Identifiers tab for public.plain.text

SwiftDefaultApps - Applications tab for public.plain.text


Historical Reference: RCDefaultApp @ web.archive.org: https://web.archive.org/web/20200312011847/http://www.rubicode.com/Software/RCDefaultApp/