Home » Linux Magazine » At Last, An X-Based vi

At Last, An X-Based vi

Dan Wilder

Issue #34, February 1997

One reader’s quest has come to a successful conclusion.

The vi editor and kin are used (if maybe not always loved) by many who value a small, nimble, no-frills programmer’s editor. The keystrokes are somewhat cryptic, but mostly just terse. With a small but sufficient command set, a rudimentary set of modes, and no scripting language to speak of, vi is extensible only by modifying the source code. But it starts up in the blink of an eye. Its keyboard response speed is just short of dazzling. Sophisticated global commands are available. The learning curve is steep at the beginning, but once the muscles have learned the commands and the brain has forgotten them, vi is both fast and effortless.

Unfortunately most vi clones have little in the way of X Windows support. When running in an xterm, some will resize nicely, and some will let you click the mouse to position the cursor. But that’s about it for mouse support. No scrollbars. X selection at your own peril. Not much other use for the mouse at all.

Enter vile-5.6, compiled for X11 as xvile.

While not perfect, the basis is solid, and this editor delivers:

  • A vertical scrollbar
  • Good integration of primary X selection
  • Mouse-based cut and paste
  • Mouse selection of regions for other commands
  • Mouse commands to open, resize and close subwindows (panes)

vi also allows commands prefaced by a colon—the so-called “colon commands”. In xvile colon commands I found a few jarring things; the release notes and help files warn about these.

While I’m no vi zealot, I’ve used vi off and on for seven years, so I’m pretty familiar with the command set. With xvile I found few surprises in the standard vi commands. Mostly, it just did what it should. Paul Fox (not the Paul D. Fox of Crisp fame), Tom Dickey, Kevin Buettner, and a host of others must have put in many long evenings on this project. MicroEMACS was the starting point, but this doesn’t look much like Emacs. No mere Emacs vi-mode, this is a vi editor down to its code. Weighing in at about 280K stripped, it is larger than conventional vi, but small enough to be nearly as fast.

Building It

After downloading the source from a sunsite.unc.edu mirror site, I unpacked it and followed the instructions in README.CFG. Configuration and build were uneventful, and xvile ran the first time I tried it.

When I typed:


a new window popped up. At a guess, I typed:


and the main help screen appeared.

Features, Good and Bad

The help screens are ordinary read-only buffers, so you can use standard search and paging commands to look through them. This is an improvement over the help I’ve seen with other vi clones. There is, however, no introductory information, and no hypertext capability. This won’t bother you if you already use vi. If you don’t and would like to try this editor, a good book might help (see Resources, page 13).

There are extensions. Among these are commands to manipulate panes, rebind keys, justify text, and so on. There is a sophisticated macro capability, which perhaps I’ll use some day, but the basic operation of the editor is fast partly because it does not at all depend on macros.

As with Emacs, functions are not inextricably bound to keys. Some Emacs commands have found their way into extensions to the colon command mode. For instance:

:bind-key undo-changes-backward u
:bind-key format-til M-w

can provide my preferred undo binding, and adds ragged-right text justification on ALT-w. These commands (without colons) also work in the .vilerc file, as do the other colon commands, so if you have some standard setup commands, you don’t have to type them every time.

If you are thinking “bind-key looks like Emacs” you are partly right. “vile” stands for “vi Like Emacs.” As the README file says, the joke is old, but somehow the name has stuck.

I wasn’t delighted with a few things. Chief among these were the weaknesses in the colon commands. For example, I’m used to typing:

:.w tmp

to write the current line to a file. xvile insists on the longer equivalent form:

:.,.w tmp

which my fingers forget to type.

Many of the colon commands originate with the ancient ed, via ex, which gives you all its formidable power for the things it does very well, such as global substitutions using regular expressions. For example, to duplicate the entire contents of lines 50 to 100 in a file, with at-signs (@) for delimiters, you might type:


and a line that looked like:


would now look like:


The most common ex colon commands are there, and do just about what you’d expect, though adding some dialogue might help the novice user. An experienced vi user just starting to use xvile should keep an eye on this dialog at first, as sometimes it asks questions that won’t be anticipated, or might indicate when a colon command is not having its intended effect. Once you learn the quirks, you can ignore the dialogue. But many less common ex colon commands are missing, or have incompatible implementations. I use these commands a lot, and it took a while for me to get used to the differences.

Keystrokes can be rebound, but mouse-clicks cannot. I’d sure like to bind some things like CTL-ALT-BUTTON3-DOWN to useful actions.

The copying policy is clouded. vile is derived from MicroEMACS, which is under a license that limits commercial use. The extensions are under GPL. Paul Fox informs me he’s tried without success to contact the MicroEMACS authors to clarify this situation. The README suggests you buy the original authors a beer if you ever meet them.

Some xvile differences are big improvements over standard vi. For instance, if you use the simplest form of the yank command to yank ten lines of text, thus:


you may then change to an alternate file:


and paste that same text with just a p. This differs from standard vi, where the text goes away on a file change.

Another annoyance of standard vi is gone. You don’t have to write your buffer to a file whenever you change windows. Don’t abuse this unless you really trust your local electric power company, and your kids don’t ever kick the power switch, or unless you don’t mind enabling automatic save to disk. But it is a nice touch, when all you want is a quick look at another file or two or three or ten.

Unlike some vi clones, when you write a file you don’t lose your place in the alternate file. In fact, xvile keeps your place in as many files as you have open.

The vertical scrollbar is handy, both for moving through the file and for telling where you are. In addition, mouse clicks on the scrollbar let you split or unsplit the window, and resize the panes.

The keypad HOME, END, PAGE UP and PAGE DOWN keys all do what you’d hope they do. So do the arrow keys. This again is different from some the vi clones.

Example xvile Window














An example xvile window is shown in Figure 1. The shaded text in the lower window is a mouse selection, to which any of those cursor-movement “operator” commands can be applied using ^s (which I’ve rebound to g). So in traditional vi, to delete a word starting at the cursor, you would type:


where d is the delete operator and w is the one-word cursor movement command. In xvile, you could also select a word (or three, or a few lines or whatever), using the mouse, then type:


Alternately, you can left-click at each end of the deletion with the d command intervening, thus: and so on with all the other operator commands, such as c (change), j (join), and so on. A complete list of these is elicited in xvile with the command:


An X selection can also be pasted by moving the mouse cursor where you want to paste, clicking the left button to set the cursor there, and then clicking the middle button to paste at the cursor. Rectangular selections are accomplished by holding down the Control key while doing the selection. Unfortunately, they are bound on the right by the shortest line included in the selection.


My search for an X-based vi is over. For me, xvile fills the bill.

If you aren’t a vi user, but you like to try a new editor once in a while, give this one a try. Don’t expect it to be self- teaching, however: you’ll need the book.

If you are already a vi user seeking to use your mouse for more than a paperweight, and if you won’t be seriously upset at having to relearn a few of your keystroke sequences, take a look at xvile.


xvile source can be retrieved via anonymous ftp from sunsite.unc.edu in the file /pub/Linux/apps/editors/vi/vile-5.6.tar.gz Use a mirror of sunsite where possible.

A good book for learning vi is Learning the vi Editor, by Linda Lamb, published by O’Reilly & Associates, ISBN: 0-937175-67-6, 192 pages, $21.95

The authors of vile are:Paul Fox, pgf@foxharp.boston.ma.usKevin Buettner, kev@primenet.comTom Dickey, dickey@clark.net

Dan Wilder is a programmer and system administrator in Seattle. He can be reached as dan@gasboy.com.