50

What are the default text editors (GUI and CLI) in different flavors of Ubuntu. what commands should we use to edit files with them?

screensho


Behind the question

I tried Kubuntu and want to try more Ubuntu flavors and other distros, but when I was in Kubuntu I tried so hard to run gksu gedit /path/file.txt which wont work because gedit isn't the default text editor in Kubuntu, it's kate. I'm glad nano was available. but if I want to try more flavors I must know what are the default text editors in various Ubuntu flavors

muru
  • 197,895
  • 55
  • 485
  • 740
  • 4
    Comments are not for extended discussion; this conversation has been moved to chat. Please post any further discussion there. Comments will be deleted from this post with no warning. – terdon May 10 '17 at 15:13

4 Answers4

52

I think Answers by Muzaffar and Terrance serves your need. One thing to note is that you can install any of these text editors in any flavors.


GUI Text Editors

Gedit

Default in:

  1. Ubuntu Desktop
  2. Ubuntu Kylin
  3. Ubuntu Budgie
  4. Ubuntu Unity

Gedit is certainly the most famous text editor in the Ubuntu world. Gedit is also available for Windows and MacOS. To install Gedit on any Ubuntu flavor use the following command:

sudo apt-get install gedit

To open a file with gedit:

gedit /path/to.file.txt

Kate

Default in:

  1. Kubuntu
  2. KDE Neon (not an official Ubuntu flavor)

it is also available for Windows. Like many KDE apps it has a load of features. To install, run:

sudo apt-get install kate

If you want the latest version of Kate, you'll need to add a PPA:

sudo add-apt-repository ppa:kubuntu-ppa/backports
sudo apt-get update
sudo apt-get install kate

To open a file with kate:

kate /path/to.file.txt

Leafpad

Unlike Kate, emphasis of Leafpad is on simplicity and lightness, which is whole agenda of the LXDE project. It comes pre-installed on Lubuntu. To install:

sudo apt-get install leafpad

To open a file with leafpad:

leafpad /path/to.file.txt

Mousepad

Default in:

  1. Xubuntu
  2. Ubuntu Studio

In philosophy, Mousepad is pretty similar to Leafpad. To install:

sudo apt-get install mousepad

To open a file with mousepad:

mousepad /path/to.file.txt

Pluma

Pluma is a fork of Gedit which comes preinstalled in Ubuntu Mate. To install:

sudo apt-get install pluma

To open a file with pluma:

pluma /path/to.file.txt

Note: if you want to edit files with root privileges, add gksu in front of a command, like this:

gksudo gedit path/to/file.txt

It's best to avoid using it with Kate.


CLI Text Editors

Nano

sudo apt-get install nano

I don't know if Nano is installed on all the Ubuntu flavors, but it's installed on Ubuntu Unity, Ubuntu Gnome and Kubuntu as per my knowledge. To open a file with nano use following command:

nano /path/to.file.txt

For more information about Nano, see The Beginner’s Guide to Nano, the Linux Command-Line Text Editor.

Vim

sudo apt-get install vim

To open a file with Vim, type either of these two commands:

vim /path/to.file.txt

or

vi /path/to.file.txt

Vim (or at least vi) is installed by default on all Ubuntu (or any other Linux) flavor. If you start to like Vim and want it to have a user interface try Gvim. Also note that on some systems, vi is aliased to vim, so both commands do identical things. (which launching vim)

For more knowledge about vim, see A Beginner's Guide to Vim or run vimtutor in the terminal.


Keep in mind that QT apps don't look good on Gtk based desktop and vice versa. but if you want them to feel at home, try this question How to make KDE applications look native in GNOME?


More Linux text editors

mcendu
  • 307
  • Comments are not for extended discussion; this conversation has been moved to chat. – Thomas Ward May 12 '17 at 13:46
  • 1
    "if you want to edit files with root privileges, add gksu in front of a command" — Please use gksudo not gksu. They have a subtle but vital difference that can, in rare circumstances, lead to data loss. Documented on the forums,on this site, and as a bug. – Paddy Landau May 16 '17 at 17:12
  • I don't know if I'd describe gvim as a user interface for vim as much as a way to run same old vim in a desktop window, so it basically just emulates a terminal window with vim in it. It does add an optional menu whose options translate to key commands, as well as mouse support with context menu, true colour support, etc, but essentially the interface is the same as in text-mode.

    Note that the version of vi installed by default is actually vim but may run vim in a "vi-compatible" mode. You can't really get the "original vi" anymore in a Linux distro.

    – thomasrutter Dec 20 '17 at 01:30
  • vi wasn't installed on my Google Cloud instance, a minimized Ubuntu 19.04 (disco dingo). It surprised me too. – mazunki Jul 29 '19 at 16:13
33

Flavors of Ubuntu can change all the time and so can the default GUI editors. Instead of trying to remember all the default GUI editors of each distro, as long as the xdg-utils are installed you can run a simple command of xdg-open so you know what the default editor is and can launch it editing a text file:

xdg-open /path/to/textfile

xdg-open can also launch what the default audio player is when you open a .MP3 file. Or if you want to quickly open a webpage you can use xdg-open www.somewebsite.com and it will launch your default web browser.


For the command line, vi/vim & nano seem to be the most common across Ubuntu flavors as being the default installed editors. vi/vim should be in all flavors of Linux.

You can change the default command line editor with the following command then you can choose which one you want as your default:

For sudo or root:

sudo update-alternatives --config editor

For your login:

update-alternatives --config editor

Example:

~$ update-alternatives --config editor
There are 9 choices for the alternative editor (providing /usr/bin/editor).

Selection Path Priority Status

0 /usr/bin/vim.gnome 60 auto mode 1 /bin/ed -100 manual mode 2 /bin/nano 40 manual mode 3 /usr/bin/emacs24 0 manual mode 4 /usr/bin/mcedit 25 manual mode 5 /usr/bin/nvi 19 manual mode 6 /usr/bin/nvim 30 manual mode

  • 7 /usr/bin/vim.basic 30 manual mode 8 /usr/bin/vim.gnome 60 manual mode 9 /usr/bin/vim.tiny 10 manual mode

Press <enter> to keep the current choice[*], or type selection number:

Then since the command /usr/bin/editor should be in your path, to edit a file you can just run the following to edit your file:

editor /path/to/file

Or if you need elevated:

sudo editor /path/to/file

Hope this helps!

Terrance
  • 41,612
  • 7
  • 124
  • 183
15

Kubuntu - kate

Lubuntu - leafpad

Xubuntu - mousepad

Ubuntu Gnome - gedit

Ubuntu MATE - pluma

Ubuntu Budgie -gedit

Ubuntu Kylin - gedit

Ubuntu Studio - mousepad

Anwar
  • 76,649
Muzaffar
  • 5,597
0

Neither

xdg-open some_file

nor

$EDITOR some_file

is foolproof, unless you DEFINE "default" as whatever they invoke, which is not the sense in which it is commonly used.

For example, on my xenial systems:

I don't have a global EDITOR variable defined:

$ env | grep EDITOR
$ echo $EDITOR

$

So $EDITOR some_file fails completely in either a gui environment (x & openbox, in lxterminal), or in a tty.

In a gui environment xdg-open some_file opens the file in vi. In a plain tty, it ATTEMPTS to do the same, but fails. But vi is not my "default" editor in the sense the word is most commonly used. All the file managers I have installed agree that my default editor is ed (no, not THAT ed - if I were that masochistic I'd use vi, my ed is a script I wrote).

There may be a justification for defining "default" in terms of one or the other of those commands, but in the general usage of the great majority of users, "default" is an adjective applied to whatever program opens a file when you double or single click on it in a gui file browser (like Nautilus, Pcmanfm, Thunar, etc.), (double or single depending on the settings in that PARTICULAR file browser). Or, alternately, whatever program opens the file when you highlight it and press enter in an orthodox file browser like Midnight Commander.

So, in the most common usage of "default", you can have a different default for each file browser, and when you speak of default without qualification it means whatever is the default in the default file browser. And the default file browser in a graphical environment would be the one that opens if you double click on a directory (aka "folder") or a symlink to a directory on the desktop, or if you don't use the desktop metaphor, maybe the one most featured in a menu. As far as I know, in this sense, which is the normal real world usage, Sumeet Deshmukh's answer is totally correct and totally complete. It may be in the more abstract senses as well.

In a non-graphical environment, outside of an orthodox file manager, the common sense of the word "default", applied to an editor, has no normal application. Nobody working in tty invokes an editor with xdg-open some_file or $EDITOR some_file unless they are working on somebody else's machine, don't want to install anything, and have gotten desperate. They open an editor by directly invoking the one they want to open, BY NAME. If they get bash: gedit: command not found they try their second favorite, etc. What the default is, is irrelevant. All that matters is their preferences and what's installed or can be installed.

The Main Point:

. . . gksu gedit /path/file.txt which wont work because gedit isn't the default text editor . . . .

Wrong. And that's why I posted, to explain why that statement is wrong and why that command failed. What the default editor is, however you define it, is irrelevant.

For that command to work, you need 2 things:

  • Both programs, gksu and gedit, must be installed on the system.

  • You must have suitable permissions for the file and it's ancestral directories. You have to have x on all directories in the path, at least r on the file itself, and probably at least r on the parent directory. Some editors might require w on the file or even on the parent directory, although they shouldn't.

You should be able to tell why the command failed by reading the error message. If you like gedit, install it.

But gksu is dangerous. Use gksudo if you need it. But don't use any of the su/sudo/gksu/gksudo/pkexec type commands unless the command that follows fails without it. And even then, only if it SHOULD have failed. If it should have worked, using some sudo-ish command to MAKE it work is like "If it don't fit, get a bigger hammer". It will create more problems down the road. In that case, correct the permissions , and try to figure why they were wrong in the first place.

Nor are any of the sudo type commands omnipotent. Sometimes, you MUST change permissions before you can edit the file even WITH gksudo.

Regarding the dangers of gksu listen to Paddy who commented on Sumeet's answer. He is wise chap who has been around a while. Repeating his 3 links:

https://askubuntu.com/a/288506/2088
https://bugs.launchpad.net/ubuntu/+source/gksu/+bug/1186676
http://ubuntuforums.org/showthread.php?t=1819589
  • 1
    Could you justify your assertion that gksu is evil? – Zanna May 23 '17 at 05:23
  • @Zanna Paddy already did, in his comment after Sumeet's answer. Check out all 3 of his links. The middle one https://askubuntu.com/a/288506/2088 is probably the clearest. – Lew Rockwell Fan May 23 '17 at 07:22
  • 1
    at least put a link in your answer then. You cannot assume everyone is reading the whole page or even that other answers will remain static. Anyway, gksu and gksudo are unnecessary imho – Zanna May 23 '17 at 07:25
  • "gksu and gksudo are unnecessary" - Maybe if you are substituting pkexec. I haven't studied it. But plain sudo isn't an adequate substitute. – Lew Rockwell Fan May 23 '17 at 07:33
  • 1
    we are "meant to" use sudo -i and then launch the program, or you can just use sudo -H. I don't use GUI text editors. I don't use the GUI for much, but I use sudo -i for anything I can't use sudo for – Zanna May 23 '17 at 07:34
  • @Zanna should I edit my answer to use sudo i, why not gksudo? everybody seems to be recommending that. – Sumeet Deshmukh May 23 '17 at 07:45
  • 2
    @SumeetDeshmukh that's up to you, but gksu is not installed by default, while sudo is of course. Sometimes you need root permissions to fix an APT problem, so installing a package is not practicable. Many people who are used to gksu still install it and use it, but it's the "old fashioned way" I guess :) I would use sudo -H gedit for example (I go around editing that -H into posts!) because really you need extra steps with sudo -i: some programs don't start in one step like that, and you have to remind people to exit the root shell, so sudo -H is the easiest way – Zanna May 23 '17 at 07:50
  • @Zanna Thnks. I know -H. I'll look up -i in the man. You do save installing 1 package I suppose. But gksudo is shorter & easier to type. Those little finger characters on the upper row are the source of most of my typos. Oh. I'll never catch up with a demon-typist if she revises while I slowly grind out my answer to the previous version ;-) – Lew Rockwell Fan May 23 '17 at 07:52
  • I think gksu and gksudo was installed by default on Ubuntu Gnome – Sumeet Deshmukh May 23 '17 at 07:53
  • @LewRockwellFan apart from this topic, your answer seems to be really good, but it's not understandable, maybe I lack in knowledge but can you make it little bit more beginners friendly and it's TL;TR (Opinion) – Sumeet Deshmukh May 23 '17 at 08:05
  • @SumeetDeshmukh Correct. Gksu and gksudo sort of have to be installed by default, and not just in Gnome - because they are part of the same package. At least so saith synaptic in Xenial. And they sure aren't going to leave out gksudo. Almost certainly installed by default in all the standard variants. BTW, I began my answer saying you should get the check mark, but . . . ahem . . . SOMEBODY edited that out. I admit I was prolix. – Lew Rockwell Fan May 23 '17 at 08:06
  • @SumeetDeshmukh It isn't clear to me what you are asking me to clarify. My whole post? Some part? – Lew Rockwell Fan May 23 '17 at 08:09
  • @LewRockwellFan that part had to get removed, Zanna is amazing at what they do. but other than that If you can improve it in some ways, try to do it in free time, but I think it serves the purpose as it is – Sumeet Deshmukh May 23 '17 at 08:11
  • @Zanna is it just gone from Ubuntu Unity or all flavors, cause I do not remember installing it || reading the link – Sumeet Deshmukh May 23 '17 at 13:30
  • @SumeetDeshmukh maybe they put it back! I seem to have it in MATE now. I am pretty sure I didn't in 16.04 – Zanna May 23 '17 at 13:32
  • @Zanna maybe some choices are made by Flavor maintainers || eg Universe and Multiverse repos are already enabled in Ubuntu Gnome and Kubuntu (I've just tried those two) – Sumeet Deshmukh May 23 '17 at 13:35
  • @Zanna Or pulled in unnoticed as a dependency. It is NOT on the big Xenial manifest: http://cdimage.ubuntu.com/xenial/daily-live/current/xenial-desktop-amd64.manifest I'm shocked. If I had a half-penny for every exclamation point I've seen after strident exhortations to use gksudo, not sudo, I'd be . . . well, at least able to start an old coin shop. And I just KNEW I was omniscient. – Lew Rockwell Fan May 24 '17 at 01:55
  • I'm using 17.04 FYI, that's why I said "maybe they put it back" - my omniscience is a bit rusty – Zanna May 24 '17 at 04:20