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?

  • 2
    I wonder if the title of this question should be something like "Replace Text Edit as the default text editor" so that it shows up in searches that don't reference sublime text. – dwightk Mar 10 '14 at 18:26
  • 1
    @dwightk good point, updated it now – wrossmck Mar 10 '14 at 18:45
  • Would it work better if you gave the file an extension, or Unhide extension in GetInfo ..? – Zo219 Sep 4 '15 at 2:35
  • 1
    @Zo219 no, some files simply do not have/need extensions, and this question is aimed at setting the default editor, not at using some sub-optimal workaround to achieve a similar result. – wrossmck Sep 10 '15 at 14:22

10 Answers 10


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 \

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 \

Remember to restart to pick up the changes.

  • 2
    @Ross Yes (or log out and back in if not root user). – grg Mar 10 '14 at 18:46
  • 1
    Hmm, so that didn't seem to work for me. (after a full restart.) And I've verified that the entry is in the right location in the launchServices.plist – wrossmck Mar 10 '14 at 19:56
  • 1
    Interestingly, it actually does work if i do open file2 in terminal or even by double clicking. I thought it wasn't working because if I get info on it, it shows that it opens with TextEdit. – wrossmck Mar 10 '14 at 20:41
  • 1
    @Justin It seems like after another full restart file->info now displays that Sublime is the default application. I'm nearly certain that I havn't done anything else to have changed the outcome. – wrossmck Apr 13 '14 at 15:57
  • 2
    On OS X Yosemite I needed to edit ~/Library/Preferences/com.apple.LaunchServices/com.apple.launchservices.secure.plist Whereas the above command created a file ~/Library/Preferences/com.apple.LaunchServices.plist which had no effect. – DonnaLea Nov 10 '15 at 1:46

Another option is to use duti (https://github.com/moretension/duti).

Run brew install duti, save a filetype like this as:

duti -s com.sublimetext.3 public.plain-text all

The changes should be applied immediately, so you don't have to restart like when editing com.apple.LaunchServices.plist.

To also change the default application for executable scripts with no filename extension, add a line like this:

duti -s com.sublimetext.3 public.unix-executable all
  • 1
    When running running duti against the file I get the error line 1: line too long. I was able to work around it by not using settings file and calling duti -s com.sublimetext.3 public.plain-text all from the cmd line – KyleMit Aug 17 '15 at 3:04
  • This worked for me. Using defaults did not work. – nathancahill Aug 26 '15 at 15:28
  • 1
    @KyleMit you need an empty line at the end of the file to avoid the line too long error. – Terry Apr 2 '16 at 2:52
  • 1
    also works with org.vim.MacVim! – ruohola Feb 20 '19 at 12:47
  • Cheers, macOS Mojave – tsujp Sep 24 '19 at 14:42

I tried grgarside's solution in the past and I believe it worked. However, on Yosemite and El Capitan, I ran into problems.

DonnaLea's comment in that solution clued me in on creating a solution. I added the folder path before com.apple.launchservices additionally the file had a slightly different name com.apple.launchservices.secure.

You can see the file/folders being modified in the following path:


Screenshot for reference: enter image description here

Here's the command I used in terminal:

defaults write com.apple.LaunchServices/com.apple.launchservices.secure LSHandlers -array-add \

Lastly, after a restart to my machine it worked as advertised.

  • 5
    Thanks for pointing out that my answer is outdated. I've indicated which versions of OS X my answer works for and provided a link to this answer. – grg Dec 22 '15 at 9:37
  • 1
    Thanks! Can confirm this to work on El Capitan. No more Text Edit when opening Podfile :) – Lord Zsolt Aug 2 '16 at 6:35
  • I have sublime text 3 installed but no com.sublimetext.3 preference file: do I need to create one? – ling Oct 13 '16 at 6:54
  1. Right click on a .txt file in Finder.
  2. Choose "Get Info".
  3. Expand "Open with:" and choose your preferred text editor in the drop-down.
  4. Push the "Change All..." button below the drop-down and then confirm in the dialog that pops up with "Continue".

This works on Yosemite (OS X 10.10).

  • 10
    This does not answer the question. The question is how to do this for all files, even those without a file extension. – wrossmck Mar 6 '15 at 11:50
  • Even if the answer is slightly off topic, it still helped me out from a Google search. +1 – Teddy Mar 6 '15 at 14:03
  • wrossmck You are basically right -- my answer even repeats the referred to Q&A in the first line of this question. But I didn't notice this until after I pieced together my answer myself from other answers on this page and posted this answer. Maybe the problem is that searches for the simple answer (i.e. .txt files) lead to this page and not the others (as @Teddy and I found). – David Resnick Mar 9 '15 at 18:55
  • @wrossmck This works for me in High Sierra. Once I did this on a .txt file, typing something like open -t script.sql still opened it in my preferred text editor that I set using these directions, even though the extension isn't .txt – Mark White Jul 4 '19 at 13:40

The solutions proposed here work perfectly for Sublime, but I wanted to do this for Visual Studio Code. The only difference is that you have to find the "application bundle identifier" for whatever text editor you use. I ran this command:

/usr/libexec/PlistBuddy -c 'Print CFBundleIdentifier' /Applications/Visual\ Studio\ Code.app/Contents/Info.plist 

link for reference

to get the identifier "com.microsoft.VSCode". Then I installed "duti" and ran this command:

duti -s com.microsoft.VSCode public.plain-text all

This should work for any text editor you want that is installed under /Applications. I hope this helps non-Sublime users.

  • 1
    Thanks! The method works for Atom (com.github.atom) as well. – RobW Dec 7 '17 at 20:10
  • 1
    Also works for MacVim (org.vim.MacVim)! – ruohola Feb 20 '19 at 12:47
  • Exactly what I was looking for. In case you're reading this and missed the instructions for installing duti above, it's here apple.stackexchange.com/a/123954/251846. – flow2k Mar 11 '19 at 18:48
  • To get duti, you can install homebrew and then run brew install duti. – Cameron Hudson Jul 20 '19 at 22:42
  • This worked for me in the past, but I'm setting up a new machine, and the duti command has no effect. The new machine is running macOS Catalina 10.15.2. – Cameron Hudson Jan 14 at 19:18

I centralize all my default apps management with Magic Launch. You can configure it to open all txt with Sublime Text as default without command line (beside, you can change it easily from System Preferences).

Magic Launch Preferences

One more exceptional useful Magic Launch’s feature is you can set rules based on filename, folders location, which I use intensively to choose different apps for development and writing.


RCDefaultApp still works on macOS Sierra. You can easily select what program is default for plain text (BBEedit in my case).

Screenshot of RCDefaultApp

  • Does this work for files which have no extension? – wrossmck Nov 2 '17 at 11:00
  • Absolutely. On the tab I am showing you basically see a graphical frontend to the command line answers. If you were interested in setting only based on extensions (why I know you are not), you would have to go to the tab "Erweiterungen" = Extensions. – traindriver Nov 2 '17 at 13:19

This solution is ripped from a YouTube video, but it works perfectly for my situation (I'm just using Sublime to edit files in languages like Python, Java, and Ruby).

For any particular file, right-click, select "More Info", and click on the "Open with" tab. You can select what text-editor you want here, and use "Change-all" to use the editor for all files of this type. Obviously, this doesn't work for files with no extension, but it's been an easy quick-fix for me.

  • This isn't as useful because you'll need to do this on an extension-by-extension basis. The question was looking for a once-and-for-all solution – wrossmck Jan 11 '16 at 19:35

Rightclick on the file --> Other --> Choose your favorite text editor (I choose Sublime text in my Applications folder) --> Check the 'Always Open with' checkbox --> Open.

This setting will be automatically applied to all other files in the machine.

No need of any restart or no need of any 3rd party software.

  • 2
    That doesn't work when there's no file extension. – grg May 13 '15 at 15:48
  • @grgarside - I don't think this works at all, regardless of the file extension. I don't really blame Hari since this is one of theose basic features that should "just work". Apple has an open bug on it (I filled it years ago, and Apple apparently refuses to fix it). – user83961 Oct 10 '15 at 13:22
  • @jww It seems to work great for me for files with extensions—it's how I usually go about changing file associations. – grg Oct 10 '15 at 14:13

First do get info on the file that you want to set sublime text as the default. Then go to the open as section and choose sublime. After that press change all then continue on the popup menu and you're doneInstructions part 1

Part 2

  • This doesn't work when the file type doesn't have an extension – wrossmck Feb 12 '16 at 8:24

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .