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.

This question already has an answer here:

None of this, this nor this worked in setting my default editor. Haven't tried this, I'm afraid it won't work either.

So how do I set the default editor to emacs or possibly emacsclient in 13.04 through the CLI/terminal?

Double-clicking on a text file still opens up to gedit.

I specifically say 13.04 because I had no problem in doing so in 11.04 from which I recently upgraded from.

share|improve this question

marked as duplicate by Eric Carvalho, Mahesh, Jorge Castro, belacq, mikewhatever Sep 21 '13 at 12:16

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

3  
To clarify, you want to set your GUI editor to a CLI editor? I think a few people are getting hung up on the CLI element but it's actually the XDG default that you're trying to alter, not $EDITOR. –  Oli Sep 16 '13 at 10:23

4 Answers 4

up vote 5 down vote accepted

This is how you set default applications..

Point and click:

Right click on the text file you want to open, choose Properties and then Open with. You should find Emacs in the Recommanded Software list. Click the Set as default button.

Using the commandline:

If you want to set default applications using the terminal, you use to XDG tool.

xdg-mime default emacs23.desktop text/plain

Then try to open a plain text document.

If you want to set default applications for the current user, edit this file:

~/.local/share/applications/mimeapps.list

To edit global settings by hand, see this file:

/usr/share/applications/default.list

Edit: Thanks to Oli how made me aware of XDG in the comments below the question

share|improve this answer
    
Explanation –  Bleeding Fingers Sep 16 '13 at 4:20
    
Please let me know if this answered it, or if you still need help with your question. Thanks! –  Nullet Sep 16 '13 at 16:44
    
one drawback I see with this approach is that it'll changes the settings for all other users –  Bleeding Fingers Sep 16 '13 at 16:49
    
See the updated answer.. –  Nullet Sep 16 '13 at 17:58
1  
It should be /usr/share/applications/defaults.list. defaults is missing the s. –  faizal Aug 14 at 14:56

Try this. Just press Ctrl+Alt+T on your keyboard to open Terminal. When it opens, run the command(s) below:

sudo update-alternatives --config editor 

When it comes up choose your editor. See image below.

enter image description here

share|improve this answer
    
nope still the same –  Bleeding Fingers Sep 15 '13 at 14:23
2  
although this does not resolve the OP, it does resolve my issue of changing the default editor used by a git commit command. –  faizal Aug 14 at 15:11
    
use select-editor I think it does the same but doesn't need sudo privileges –  Akronix Sep 24 at 23:14

Go to system settings -> Details -> default applications and select Emacs as the default application for files. I did this yesterday and it works fine...

share|improve this answer
    
I had the option of doing that, but I prefer doing it through the CLI because that way I get much more insight on what goes around behind the scene. –  Bleeding Fingers Sep 16 '13 at 4:19
    
So you don't want a solution that works instead you want to find a harder way to do it? -_- –  Alvar Sep 16 '13 at 10:13
    
@hus787 actually, everything is still done behind the scene, using CLI or GUI. If you want to know, you may need to dirty your hands as Oli is suggesting and edit files at hand. –  Braiam Sep 16 '13 at 13:37

I have already asked a similar question about changing all the associations for Gedit to Sublime Text (another GUI editor).

That's essentially where you answer lies except instead of using a .desktop file for Sublime Text, you'll be adding one (if one doesn't exist) for Emacs and then just changing all the associations to that.

share|improve this answer
    
if the answers out there work for me/13.04. I'll then have to ask you/moderator to mark this question "duplicate". Or I will flag it. –  Bleeding Fingers Sep 16 '13 at 10:53
    
flagged as duplicate –  Bleeding Fingers Sep 16 '13 at 17:00

Not the answer you're looking for? Browse other questions tagged or ask your own question.