Domanda

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?

È stato utile?

Soluzione

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.

Altri suggerimenti

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

Some files are also considered 'public.data', not 'public.plain-text', so you can do this as well:

duti -s com.sublimetext.3 public.data all

I tried grg'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:

/user/Library/Preferences/com.apple.LaunchServices/com.apple.launchservices.secure.plist

Screenshot for reference: [![enter image description here][1]][1]

Here's the command I used in terminal:

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

Lastly, after a restart to my machine it worked as advertised. [1]: http://i.stack.imgur.com/qQOQg.jpg

  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).

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.

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

I am using Catalina 10.15.6. Taking the following two steps worked for me.

Save SublimeText files with ".txt" extension by default

  1. Open SublimeText.
  2. Go to SublimeText > Preferences > Settings.
  3. Add the following line into the "Preferences.sublime-settings--User" file: "default_extension": "txt",
  4. Save and close the updated settings file.

Configure your Mac to open all ".txt" files with SublimeText by default

[Follow these steps, as posted by David Resnick in a prior answer]

  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 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.

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.

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

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a apple.stackexchange
scroll top