Roundup: Text Based Text Editors

  • July 7, 2010
  • Avatar for peter
    Peter
    Upfold

Keyboard photo by john_a_ward on Flickr

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 logo

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

GNU nano logo

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

Vim logo

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.

%{font-size:0.8em}Keyboard image at top of post is by Flickr user john_a_ward. Licensed under CC-BY 2.0 GB

Avatar for peter Peter Upfold

Home » Articles »