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.

  • 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 Answers4

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

Mitch
  • 107,631
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

Nullet
  • 3,014
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.

Oli
  • 293,335
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...

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