6

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.

1
  • 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, 2013 at 10:23

4 Answers 4

15

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

3
  • nope still the same Sep 15, 2013 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, 2014 at 15:11
  • 2
    use select-editor I think it does the same but doesn't need sudo privileges
    – Akronix
    Sep 24, 2014 at 23:14
9

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

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

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.

2
  • 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. Sep 16, 2013 at 10:53
  • flagged as duplicate Sep 16, 2013 at 17:00
0

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

4
  • 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. Sep 16, 2013 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, 2013 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, 2013 at 13:37
  • Doesn't work in 16.04 anyway...as with so many Ubuntu niceities, they are short lived...
    – Dave
    Jun 17, 2016 at 15:03

Not the answer you're looking for? Browse other questions tagged .