Right click on a text file, point to "Open With" and it'll show other editors in a sub-menu. Click on "Other Application...". It'll show you a dialog with a list of applications, select Emacs and make sure the "Remember this application for "plain text document" file" option is checked. Click "Open".
On Ubuntu 20, you need to change the gnome-text-editor alternatives link from gedit to the one you want. However, there usually is only one such editor detected so update-alternatives --config won't work; you'll have to add the editor you want.
If you would like to replace gedit with any other text editor for all file types, the easiest is to edit the defaults.list file located here:
/usr/share/applications/defaults.list
Just find and replace all gedit.desktop references with your own editor (in this case emacs.desktop).
You need root permissions to edit the file. So, just do:
Here is what worked in my case:
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.
In some cases:
A more robust solution would be to replace the bindings in
/usr/share/applications/defaults.list
.Right click on a text file, point to "Open With" and it'll show other editors in a sub-menu. Click on "Other Application...". It'll show you a dialog with a list of applications, select Emacs and make sure the "Remember this application for "plain text document" file" option is checked. Click "Open".
I don't use a DE, but for my configurations the next command is the best:
Man pages
select-editor
If you are working from the terminal then I would add the following to your .bashrc file (or the config file for your favorite shell):
You can set the default text editor for a specific user in # ~/.local/share/applications/mimeapps.list by:
For global configuration for all users you have to modify the /etc/gnome/defaults.list
On Ubuntu 20, you need to change the
gnome-text-editor
alternatives link fromgedit
to the one you want. However, there usually is only one such editor detected soupdate-alternatives --config
won't work; you'll have to add the editor you want.E.g. to add
notepadqq
:If you would like to replace gedit with any other text editor for all file types, the easiest is to edit the
defaults.list
file located here:Just find and replace all
gedit.desktop
references with your own editor (in this caseemacs.desktop
). You need root permissions to edit the file. So, just do:Save the file, close it and it's done.