MacOS – Replace Text Edit as the default text editor

launch-servicesmacostext-editor

I've seen questions like this which don't quite solve my problem.

I'd like to make Sublime Text 3 the default file viewer/editor for all files that currently use textedit.

Most of these files can be command+i'd, but the ones that have no extension cannot. They give all sorts of permissions errors such as the ones in this image not enough information is available

Is there any way to just never use textedit, and instead set sublime as the default editor for all files?

Best Answer

To set Sublime Text as the default handler for public.plain-text:

Mavericks (10.9) and earlier

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

Yosemite (10.10) and later

Use com.apple.LaunchServices/com.apple.launchservices.secure.

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

Remember to restart to pick up the changes.

Related Question