Change all associations from gedit to another application

Running on 13.04+, update the file: /etc/gnome/defaults.list.

sudo sed -i 's/gedit.desktop/sublime-text-2.desktop/g' /etc/gnome/defaults.list  

Credit to trent for the update to 13.04+

Pre-13.04:

System wide associations:

sudo sed -i 's/gedit.desktop/sublime-text-2.desktop/g' /usr/share/applications/defaults.list

Just your user's associations:

sed -i 's/gedit.desktop/sublime-text-2.desktop/g' ~/.local/share/applications/mimeapps.list

Credit to Oli for the naming convention of the .desktop file before I started using SublimeText2.


Update for 16.04 Users:

Ubuntu tweak has been discontinued. Much of it's functionalities are now being provided by Unity Tweak Tool or Gnome Tweak Tool. But those still lacks Ubuntu Tweak's awesome feature of easy file-type association changing.

To install Ubuntu Tweak on these later version follow the procedure described on this answer about installing it on 16.04


There is another way to change the association. It is via using Ubuntu-tweak.

  1. Install Ubuntu tweak

    • How do I install Ubuntu-Tweak?
  2. Open it via Dash by typing "Ubuntu tweak"

    enter image description here

  3. After opening it, Click on the Admin tab.

    enter image description here

  4. Then click on File type manager section

    enter image description here

  5. Then first select the Text catagory from the left side bar, and then click on the Associated Applications column to sort it by Application name

    enter image description here

  6. After the application is sorted by name, Select the top entry with Gedit, then Press and hold the Shift key and click on the last entry with gedit. Then click on the Edit button.

    enter image description here

  7. A new window will open where you can see all installed text editor.

    enter image description here

  8. Then select the desired application from list and click close. You can also Click on the Add button to add an application which is not installed in pre-defined system folder.

Hope this will help. If you want to reset them, you can click the reset button also.

The good thing in this solution is, you can't accidentally mess up your system .desktop file.


The easiest way to do is using the nautilus files not sure if it works for others too

  1. select the type of file you want right click and select properties (Alt+Enter is the shortcut)

  2. The choose the option open with and then select the one you want as you see here I use atom by default you can also select sublime from the recommended applications enter image description here

Command line editor

you you want to choose the default editor in command line type the following command and then choose the option from there

sudo update-alternatives --config editor

since I use vi I have set it to vim you can choose what ever you want from there also here is the screen shot

screen shot

If you like this don't forget to vote up this post