For some reason, text editors are something that us Unix geeks get very passionate about. Whether it’s an argument over which editor is better, or just professing our love for our favourite keyboard shortcuts, it’s an emotive issue.

You might think that a plain text editor is a pretty simple affair. After all, all it has to do is allow you to type stuff in and then change it. Right?

Well, it turns out that there are lots of different ways you can approach a text editor and lots of different feature sets that different people prefer.

Why a text-based text editor?

If you’ve used a desktop Linux distribution recently, you’re probably familiar with programs such as gedit, Kate or maybe LeafPad. These are, of course, text editors, but they are graphical programs.

Text editors that run in the command line environment are what we are looking at here. But why would you use any command line based text editor in preference to a graphical one?

It will run everywhere. If you need to SSH into a remote server, for example, where you only have access to the command line, these editors will be your only option. So learning one of the common editors can come in very handy.

Extensible and customisable. The flexibility and power offered by some of these tools is unparalleled. If you don’t like the way the application works, you can tweak it and hack it and script it until you do. Getting the same degree of configurability is much more difficult with GUI apps.

The keyboard. While there’s a learning curve to any set of keyboard shortcuts, putting in the time to grok the keyboard interface can make text editing much more efficient, especially for doing more complex tasks which would require many clicks in a GUI.

Geek is the new chic. Seriously, you can’t deny there’s a certain sense of satisfaction one gets from using something really geeky. If you’re into that sort of thing…

So, let’s take a look at three of the most common editors, in alphabetical order.

GNU Emacs

Emacs describes itself as “the extensible, customisable, self-documenting, real-time display editor”. It is arguably the most powerful and configurable text editor available and has a long history. The software contains its own programming language, a version of Lisp called Emacs Lisp. This means that pretty much every feature is customisable, such that you can even have 'applications’ that run inside of Emacs (there is a text adventure game called Dunnet and many other 'games’ for Emacs). It even has a built-in web browser.

As a consequence of its 1970s heritage, for someone that has never used it before, the way it works might be unfamiliar. For example, it refers to the 'Meta’ key, which refers to what is now the Alt key on modern PCs.

It is probably fair to say, however, that its extensibility and programmability is unparalleled. If you do want complete control, Emacs is an über-editor.

Advantages

Infinitely configurable.

More than just a text editor — can become a whole operating environment!

Disadvantages

Quite a steep learning curve, with many keyboard shortcuts to memorise.

Some argue it is too 'heavyweight’ with resource usage.

GNU nano

Modelled around pico, an editor that derived from the Pine email client (though wasn’t under a free software licence), GNU nano is probably the most lightweight of the three editors here and also probably the easiest for new users to immediately get familiar with.

It, helpfully, lists the most common keyboard commands you might need to use at the bottom of the screen (^ denoting Ctrl), so even if you have never used it before, it is pretty easy to work out how to create a new file and save it without having to read any documentation.

The name implies that it is mean to be small and light — you won’t find masses of unnecessary functionality, as it is designed to be just a text editor, rather than something like Emacs which is a whole platform in itself. You will also have less configurability and options, although it’s still possible to do quite a bit of interface tweaking.

Advantages

Easy to get started with — common commands are always listed at the bottom of the screen.

Lightweight and simple, just a text editor with nothing else you may not need.

Disadvantages

Does not offer the same degree of flexibility and extensibility as other editors.

For serious editing tasks, a lack of advanced features.

vi/vim

Like Emacs, vi and the 'vi improved’ version, Vim, have been around for some time. The original editor, vi, was written in 1976 for BSD Unix, while Vim was written later, in 1991, for the Amiga. For a long time, it was essentially the standard Unix editor until Emacs gained popularity. Inclusion of vi is still a requirement for an operating system to be covered under the Single Unix Specification and the POSIX standard.

The 'improved’ version, Vim, has an internal scripting language which means that it can be customised in many ways, as well as sophisticated syntax highlighting support.

One of the biggest differences between vi and other editors is that it uses a modal interface. There is an insert mode and a normal mode. Any keys you press are only actually 'typed in’ when you are in insert mode. Any keys you press in normal mode are commands. This can be potentially destructive if you are not careful about which mode you are in! The modal way of working, though, does mean the user avoids frequently having to use modifier keys like Control, which in theory can improve typing ergonomics for experienced users doing heavy editing.

Advantages

A version will ship on every Unix operating system — you know it will be available.

Configurable and scriptable.

Disadvantages

New users might find the modal nature interface very confusing at first.

Not capable of doing everything as an 'operating environment’ as Emacs can.

Everyone has their own preference…

As I mentioned in the intro, which editor you pick is an emotive issue for Unix geeks. If you’re someone less familiar with the command line, but you still do need to learn a command line-based editor, nano is probably the way to go initially, just because of its simple operation and the fact that it shows you the keypresses you need to make.

If you’re more experienced, you’ll either already have a preference for vi or Emacs and you’ll probably be sticking to it. If you don’t, though, give them both a try and see what you like best.

Personally, I’ve always used vim for my command line editing needs. I am lazy, however. I probably only use a tiny percentage of vim’s functionality, and there are many things I should spend more time learning to speed up repetitive tasks. The point is, though, I can get what I need to done, and whichever system I find myself on, I know there is something there I can use.

What is your favourite editor and why? Are there any editors other than these that deserve a mention? Have your say in the comments.

Peter Upfold is a technology enthusiast from the UK. Peter’s interest in Linux stems back to 2003, when curiosity got the better of him and he began using SUSE 9.0. Now he runs Linux Mint 9 on the desktop, runs a CentOS-based web server from home for his personal website and dabbles in all sorts of technology things across the Windows, Mac and open source worlds.

I prefer Vi(m) purely because it's always there, as you've said in the post. Used to be a fan of nano but got tired of trying to edit files on systems without it installed, so switched to the much more powerful alternative and never looked back.

Farrell McGovern(guest)

Ick! I've used VI(m), EMACS and Nano...but the editor I really like is JOE, in the JSTAR mode. There once was a time when the standard text editor control commands were based upon WordStar's editor. Now, in the point and clicky universe, no one remembers Wordstar, except for people who write professionally.

Padma(guest)

I started in *nix in the 80s, administrating a bunch of SVR2 machines. I became quite proficient with vi.

Ten years later I was working on Sun SOlaris systems, and emacs was the editor of choice in that shop. Again, I became quite proficient, and even hack some lisp to improve my workflow.

Today, I am working in a CLI-only environment, and the editor we have is vim. I have fallen in love, again. I have scripts and plugins helping me out to the extent that it's practically an IDE. The more I use it, the more I love it.

Le Hoang Long(guest)

Michael(guest)

Unfortunately, I'm finding that all the text editors in Linux are kinda crap (or at the very least seriously outdated when compared to modern standards), both GUI and text based. I use vim for quick edits, and Kate for longer coding, but they are both rather lacking. Emacs, Vim, Kate, Nano, Pico, GEdit, joe, anjuta, eclipse, all have issues as far as I'm concerned. I wouldn't think my desired features are all that strange:

No mode switching. You type it and it appears in the buffer.

Menu system for all commands and settings. Alt-hotkey moves your focus into the menu system, Esc key gets you out of it.

Cursor movement with arrow keys. Pressing the up arrow moves the cursor directly up, regardless of what is in the previous line. (i.e. don't go to the far left margin if the line only contains a carriage return)

Easily redefine hotkeys for all commands and navigation.

Easily list all (multiple) files that are open and navigate among them.

Both linear and column selection modes.

Most of these features are standard on any GUI app across multiple platforms. Yet Linux and Unix, famed for the power of the command line, have some of the most difficult to use text editors out there. The editors are either powerful and extremely difficult to use, or are easier but have such sparse functionality as to make them useless for anything but the simplest edits.

Grrr... Can anyone suggest a text mode editor that follows modern interface standards?