Last Updated: January 04, 2021
· jonstaff

Setting Sublime Text as the Default Editor OSX

Let's face it - TextEdit is mediocre at best. Sublime Text is leaps and bounds ahead of most text editors out there (if you didn't know that already, it's definitely work checking out).

So how can we swap TextEdit for Sublime? Simple.

Just enter the following into Terminal (Note: a restart is required for these changes to take effect):

defaults write LSHandlers -array-add {LSHandlerContentType=public.plain-text;LSHandlerRoleAll=com.sublimetext.2;}

Any plain text files should now open directly in Sublime Text and you'll be able to use the command line open -t <filename> to open files with Sublime.

Alternatively, you could find a plain text file in Finder and click 'Get Info'. Under 'Opens with:', select Sublime Text and click 'Change All...'

3 Responses
Add your response

For Sublime Text 3:
defaults write LSHandlers -array-add '{LSHandlerContentType=public.plain-text;LSHandlerRoleAll=com.sublimetext.3;}'


over 1 year ago ·

This is great, allows you to specify the default for the content type, rather than the file extension.

But the snippet given above didn't work for me, I had to quote the content like in k-funk's example. ie:

defaults write LSHandlers -array-add "{LSHandlerContentType=public.plain-text;LSHandlerRoleAll=com.sublimetext.2;}"
over 1 year ago ·

Unfortunately this doesn't work on Mojave.

The Get Info workaround also does not work, if the file does not have an extension. It only works for this specific file where you set it.

over 1 year ago ·