Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

How can I change my default text editor from gedit to Emacs?

share|improve this question

6 Answers 6

up vote 7 down vote accepted

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".

share|improve this answer
1  
I did try this, but I'm having a bit of a problem - whenever I double-click on a file in Nautilus, I get a dialog box that says: "Do you want to run "tasks.css", or display its contents? "tasks.css" is an executable text file." And then there are four options - Run in Terminal, Display, Cancel, Run. (This happens with every file, not just CSS files.) –  begtognen Nov 16 '10 at 12:05
3  
@begtognen: Sorry for the ultra-late reply. But I've been trying to find a solution for this myself. Just found one - go to Nautlius preferences (Edit > Preferences), select the "Behavior" tab and under the "Executable Text Files" section, select the radio button "View executable text files when they are opened". Fixed the issue for me. –  Mussnoon Nov 22 '10 at 23:28
    
YES! Worked beautifully. Thanks so much. –  begtognen Nov 24 '10 at 23:16
    
I tried this also, but Emacs doesn't appear in the list of applications. Any thoughts? –  MTS Apr 1 at 19:44

The answer didn't work on 12.10. 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.

share|improve this answer
    
It does not work on 13.04. After Step 3, I see a lot of choices, but not the editor I would like to have .... of course, the idea would be to use 'Add' ... but this is grayed out and can't be selected. Argh –  Marius Hofert May 23 '13 at 15:24
    
worked for me on 13.10 (replaced gedit with geany) –  Alexander Malakhov Jan 29 at 9:35

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):

export EDITOR=emacs
share|improve this answer

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
share|improve this answer
    
I don't know how, but by copying this command I accidentally cleared the whole file. I would much prefer doing this in a text editor using find-replace (as explained in this answer) for those who are not too familiar with sed. –  kermit666 Apr 5 '13 at 22:37

Go to your piece you want to edit.

  1. Select properties.

  2. Select change.

  3. Change it to what you want the default editor to be.

share|improve this answer

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
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.