Take the 2-minute tour ×
Ask Different is a question and answer site for power users of Apple hardware and software. It's 100% free, no registration required.

I'm a developer and often dealing with unusual file types. If I want to open one of these files in TextEdit, I have to start it first and then open the file with it, or drag the file to the TextEdit icon.

Is there a way to permanently put the TextEdit.app into the Open with... menu list no matter what file type I'm looking at?

Of course this procedure will be useful for whatever text editor you choose if TextEdit isn't your cup of tea.

share|improve this question
    
I have this desire, also. Currently, I keep TextEdit in my Dock, so it is always available to drag a file onto. –  GEdgar May 2 '13 at 18:30

4 Answers 4

up vote 13 down vote accepted

The only way to do this with all file types is to create a service in automator, which actually should make things easier for you.

  1. Open Automator and select "Service".
  2. In the "Service receives selected..." dropdown, change it to read "receives selected files and folders in any application"
  3. Select Utilities from the library menu in the left pane and double-click "Run Shell Script"
  4. Change the "Pass Input" dropdown to "as arguments"
  5. Delete the default script and replace with the following:

if [ -f "$1" ] ; then open -a "TextEdit" "$1" ; fi

Save this file as whatever you want it to show up as in your contextual menu, something like "Open With TextEdit" and you're done, you'll now have the option to open any file with text edit.

It won't be in the open with menu, it will be a separate item in the contextual menu grouped with any other services you have running.

On a side note, if you're developing on a mac you should really think about using a better text editor like TextMate or TextWrangler or Sublime Text, some of these even add the service for you to save you doing all of the above.

share|improve this answer
1  
+1, and yeah, TextEdit isn't a real plaintext editor--it can do it, but it doesn't have any features to make it easier, and would much rather be editing rich text. –  NReilingh Aug 13 '12 at 22:18
    
Beautiful! It would be even better if we could restrict this to all files in a text format (including source code and the like) –  William Jockusch Mar 8 at 16:39
    
is there any way to make it appear in the main menu instead of having to search for in the service menu? Or at least to hide unused items in service menu... –  pqnet Aug 12 at 8:24

You can add supported file types by editing the Info.plist, but I don't know any way to do that for all file types. Adding UTIs like public.data or public.item to an Info.plist or com.apple.LaunchServices.plist doesn't seem to work.

I have used duti to make TextMate the default application for different plain text types:

# plain text files without an extension
com.macromates.TextMate.preview public.plain-text all

# executable scripts
com.macromates.TextMate.preview public.unix-executable all

com.macromates.TextMate.preview .as all
com.macromates.TextMate.preview .ass all
com.macromates.TextMate.preview .bash all
com.macromates.TextMate.preview .bom all
com.macromates.TextMate.preview .c all
com.macromates.TextMate.preview .cfm all
com.macromates.TextMate.preview .cfml all
com.macromates.TextMate.preview .class all
com.macromates.TextMate.preview .coffee all
com.macromates.TextMate.preview .conf all
com.macromates.TextMate.preview .cpp all
com.macromates.TextMate.preview .css all
com.macromates.TextMate.preview .csv all
com.macromates.TextMate.preview .ctp all
com.macromates.TextMate.preview .dat all
com.macromates.TextMate.preview .data all
com.macromates.TextMate.preview .doc all
com.macromates.TextMate.preview .erb all
com.macromates.TextMate.preview .fields all
com.macromates.TextMate.preview .gemspec all
com.macromates.TextMate.preview .h all
com.macromates.TextMate.preview .haml all
com.macromates.TextMate.preview .hotkey all
com.macromates.TextMate.preview .hpp all
com.macromates.TextMate.preview .idx all
com.macromates.TextMate.preview .java all
com.macromates.TextMate.preview .js all
com.macromates.TextMate.preview .json all
com.macromates.TextMate.preview .keylayout all
com.macromates.TextMate.preview .kmlibrary all
com.macromates.TextMate.preview .less all
com.macromates.TextMate.preview .log all
com.macromates.TextMate.preview .m all
com.macromates.TextMate.preview .manifest all
com.macromates.TextMate.preview .md all
com.macromates.TextMate.preview .mm all
com.macromates.TextMate.preview .msass all
com.macromates.TextMate.preview .opml all
com.macromates.TextMate.preview .pg all
com.macromates.TextMate.preview .php all
com.macromates.TextMate.preview .pl all
com.macromates.TextMate.preview .plist all
com.macromates.TextMate.preview .plist all
com.macromates.TextMate.preview .py all
com.macromates.TextMate.preview .rb all
com.macromates.TextMate.preview .rd all
com.macromates.TextMate.preview .rdoc all
com.macromates.TextMate.preview .readme all
com.macromates.TextMate.preview .rhtml all
com.macromates.TextMate.preview .rst all
com.macromates.TextMate.preview .sb all
com.macromates.TextMate.preview .scss all
com.macromates.TextMate.preview .sh all
com.macromates.TextMate.preview .srt all
com.macromates.TextMate.preview .strings all
com.macromates.TextMate.preview .sub all
com.macromates.TextMate.preview .tex all
com.macromates.TextMate.preview .tsv all
com.macromates.TextMate.preview .utf all
com.macromates.TextMate.preview .xml all
com.macromates.TextMate.preview .yaml all

duti doesn't support just adding applications to open with menus without making them default though.

share|improve this answer

You can create a Service menu workflow as influencejamie describes. However you can just use the 'Open Finder Items' option and add TextEdit as the app.

There is a good post about it here, which explains how to create the workflow in more detail.

share|improve this answer
1  
Answers on Ask Different need to be more than just a link. It's okay to include a link, but please summarize or excerpt it in the answer. The idea is to make the answer stand alone. –  patrix May 2 '13 at 19:04

Just use the option "-e" to open with TextEdit: open -e yourfile.whatever and it'll open it in TextEdit.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.