Ubuntu – How to associate file types with Sublime Text 2

file associationsublime-text

I installed Sublime Text using this tutorial http://www.technoreply.com/how-to-install-sublime-text-2-on-ubuntu-12-04-unity/

I want to associate Sublime with css, js and php files. I added the following rows but still when double click on a php, js or css file, it does NOT open it at all (not just with Sublime):

text/php=sublime.desktop
text/x-php=sublime.desktop
application/php=sublime.desktop
application/x-php=sublime.desktop
application/x-httpd-php=sublime.desktop
application/x-httpd-php-source=sublime.desktop
text/javascript=sublime.desktop
text/css=sublime.desktop

How should I proceed?

Best Answer

This is how I changed the default editor for multiple file types in 12.04:

  1. Right click the file in question
  2. Choose 'Properties'
  3. Select the 'Open With' tab
  4. Choose 'Sublime Text' under 'Related' or 'Recommended' Applications
  5. Select 'Set as default' option on the bottom right

If Sublime Text doesn't show up on this list, make sure it's fully installed via the package manager.

Unfortunately I haven't found a way to do this in batch yet and a previous method of opening some hidden file and doing a find and replace for sublime text didn't work for me.

Related Question