Roundup: Text Based Text Editors

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.

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 - http://peter.upfold.org.uk/

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.

Home » Articles »

Discussion: Roundup: Text Based Text Editors

  1. Sam Boswell (guest)

    # Posted on 07 July 2010 at 09:13 AM

    I once made myself sit down and practice in emacs till i was comfortable using it - and not looked back - it's my editor of choice just because of it's power/flexibility :)



  2. # Posted on 07 July 2010 at 05:16 PM

    Emacs is an addiction.

    As a result of my addiction I run StumpWM, Conkeror, tmux with emacs key commands, and live the rest of my life in the shell.



  3. # Posted on 07 July 2010 at 11:25 PM

    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.



  4. Farrell McGovern (guest)

    # Posted on 09 July 2010 at 05:38 AM

    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.



  5. Chris H (guest)

    # Posted on 09 July 2010 at 06:58 AM

    Good article. I've always tried to learn emacs but given up, now I'll have another go!

    I remember Wordstar! Used to use it on an ACT Sirius computer many yeas ago.



  6. Tohdol (guest)

    # Posted on 09 July 2010 at 09:41 AM

    The Hessling Editor (THE) is the editor I stick to. "Folding" and Rexx based Macro are outstanding... Neither Emacs nor Vim does it enough. http://hessling-editor.sourceforge.net



  7. Padma (guest)

    # Posted on 09 July 2010 at 04:02 PM

    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.



  8. Le Hoang Long (guest)

    # Posted on 10 July 2010 at 09:12 AM

    I am using Vim all *nix distros come with it and it is not too complicate as emacs



  9. Michael (guest)

    # Posted on 13 July 2010 at 01:05 AM

    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.
    • Ctrl-S saves. Ctrl-C copies selected text (or current line), Ctrl-X cuts selection. Ctrl-V pastes. Ctrl-Z calls undo. Ctrl-Q exits.
    • 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?

    Thanks! Michael



  10. Colin (guest)

    # Posted on 14 July 2010 at 10:26 AM

    There's some more great text editors listed in http://www.linuxlinks.com/article/20080824052425167/Editors.html



Home » Articles » Roundup: Text Based Text Editors

Sign In