How do I change the default text editor?

Here is what worked in my case:

  1. Right click on a text file.
  2. Choose "Properties" (not "Open With...")
  3. Click on the "Open With" tab.
  4. Choose your new text editor.
  5. Mark chosen text editor using a button "Set as default".

This also works on 12.04 and 13.04.

@ Edit: based on comments it does work on all distros until 20.04


To change default text editor across the file types, try updating gnome-text-editor configuration.

sudo update-alternatives --config gnome-text-editor

In some cases:

sudo update-alternatives --config editor

A more robust solution would be to replace the bindings in /usr/share/applications/defaults.list.

sed -i 's/gedit/emacs/' /usr/share/applications/defaults.list