59

How can I set TextMate as default text editor on Mac OS X?

I've tried it with

ln -s /Applications/TextMate.app/Contents/Resources/mate ~/bin/mate export EDITOR='mate -w' 

but that doesn't work.

2

8 Answers 8

93

Just right (or control) click a file of the type you want to change and:

"Get Info" -> "Open with:" -> (Select TextMate) -> "Change All"

Sign up to request clarification or add additional context in comments.

6 Comments

keep in mind, this will be on a per file extension basis, so you will have to do it for a file of each file extension you want textmate to be the default editor for.
Correct, I've done this for Sublime editor. Sweeping changes make me a bit nervous that it will go way too far (good luck rolling back) and there's really only a handful of file types that need altering. I do them on an as needed basis.
Hi,I do as you said,but only work for one file,not for all of them.
@Ben After selecting TextMate from the drop down you must hit the "Change All..." button and confirm. It most definitely works, as I said I do this myself.
@Ben you need to make sure and actually right click > Get Info, and look for 'Open with:' in that Info view. This is different then right clicking and doing 'Open With' right from that first menu. I initially made this mistake and it changed only that one file.
|
44

The method through Finder is not practical. If you're a developer, your files likely include .profile, .gitconfig, .bashrc, .bash_profile, .htdocs, etc.

The best way to do this is in Bash (for Sublime Text 3):

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

For other text editors, I assume you can replace 'com.sublimetext.3' with the proper string. You could probably Google for your text editor's name + "LSHandlerContentType=public.plain-text" to figure out what your app's string would be.

For me, this changed the defaults for both Finder, and

$ open ~/.bashrc 

10 Comments

Most of us only use one text editor at a time. Finder changes the default for a given filetype, but who wants to change it for .html, .htm, .sh, .py, .txt, .css, .conf, .prod-conf, .staging-conf, .dev-conf (or whatever other developers on a team might call certain configuration files), .md, .gitconfig........ the list is endless. TextEdit is a HORRIBLE text editor. Sweeping changes are good when it replaces that CRAP software that defaults to rich text, which may break something if you open/save with it because you haven't yet marked this filetype using Finder.
This is the specific answer I was looking for, since I was trying to set the default editor for dotfiles that contain preferences. Thank you.
For other editors the string can be found in the app's Info.plist. Right click the app in question -> show package contents -> open Contents-> open Info.plist with a text-editor -> locate the key CFBundleIdentifier-> the string value below is the string in question.
Info.plist for Textmate 2 is CFBundleIdentifier = com.macromates.TextMate.preview"; but that didn't seem to work for me
this doesn't work on mac-os sierra. for me "open .bash_profile" is still opened by textmate :(
|
2

Have you modified your shell PATH environment variable to include ~/bin? That directory is usually not included in PATH by default on OS X. It might be simpler to create the symlink in /usr/local/bin which is usually included in PATH. Try:

echo $PATH 

Comments

2

This worked for me on OS X v10.11 (El Capitan):

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

Comments

2

For TextMate 2:

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

And you need to restart after that.

Comments

1

To change the default text editor across the board, use the aforementioned method (i.e., "Get Info" → "Open with:" → (editor of choice) → "Change All") on .txt files. Then it will be used as the default editor for any text-based file that doesn't yet have an application preference for its extension.

For instance, if you use the terminal, the command open -t will use your preferred text editor, which is whatever application is associated with .txt files. By default this is (you guessed it) TextEdit, unless you explicitly specify otherwise.

Comments

0

I found Replace Text Edit as the default text editor on apple.stackexchange which works really well.

For developer-type files like .gitignore, use the last option provided:

duti -s com.macromates.TextMate public.data all 

Substitute your editor's CFBundleIdentifier as needed. To find it, locate the application file, right-click and choose Show Package Contents, then open Info.plist in the Contents folder. CFBundleIdentifier should be near the top...

This work on Catalina. I'll update my answer if/when I update my OS.

Comments

0
  1. https://macromates.com
  2. Download
  3. Expand Archive file
  4. Move TextMate app into Applications
  5. Open TextMate within Applications
  6. Open TextMate settings
  7. Select Terminal and install Shell support
  8. Open system terminal and command git config --global core.editor "mate -w"
  9. git config --global -e

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.