At Last, An X-Based vi
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.
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.
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:
to write the current line to a file. xvile insists on the longer equivalent form:
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.
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.
Practical Task Scheduling Deployment
One of the best things about the UNIX environment (aside from being stable and efficient) is the vast array of software tools available to help you do your job. Traditionally, a UNIX tool does only one thing, but does that one thing very well. For example, grep is very easy to use and can search vast amounts of data quickly. The find tool can find a particular file or files based on all kinds of criteria. It's pretty easy to string these tools together to build even more powerful tools, such as a tool that finds all of the .log files in the /home directory and searches each one for a particular entry. This erector-set mentality allows UNIX system administrators to seem to always have the right tool for the job.
Cron traditionally has been considered another such a tool for job scheduling, but is it enough? This webinar considers that very question. The first part builds on a previous Geek Guide, Beyond Cron, and briefly describes how to know when it might be time to consider upgrading your job scheduling infrastructure. The second part presents an actual planning and implementation framework.
Join Linux Journal's Mike Diehl and Pat Cameron of Help Systems.
Free to Linux Journal readers.View Now!
|The Firebird Project's Firebird Relational Database||Jul 29, 2016|
|Stunnel Security for Oracle||Jul 28, 2016|
|SUSE LLC's SUSE Manager||Jul 21, 2016|
|My +1 Sword of Productivity||Jul 20, 2016|
|Non-Linux FOSS: Caffeine!||Jul 19, 2016|
|Murat Yener and Onur Dundar's Expert Android Studio (Wrox)||Jul 18, 2016|
- The Firebird Project's Firebird Relational Database
- Stunnel Security for Oracle
- My +1 Sword of Productivity
- SUSE LLC's SUSE Manager
- Managing Linux Using Puppet
- Non-Linux FOSS: Caffeine!
- Murat Yener and Onur Dundar's Expert Android Studio (Wrox)
- Parsing an RSS News Feed with a Bash Script
- Google's SwiftShader Released
- Doing for User Space What We Did for Kernel Space
With all the industry talk about the benefits of Linux on Power and all the performance advantages offered by its open architecture, you may be considering a move in that direction. If you are thinking about analytics, big data and cloud computing, you would be right to evaluate Power. The idea of using commodity x86 hardware and replacing it every three years is an outdated cost model. It doesn’t consider the total cost of ownership, and it doesn’t consider the advantage of real processing power, high-availability and multithreading like a demon.
This ebook takes a look at some of the practical applications of the Linux on Power platform and ways you might bring all the performance power of this open architecture to bear for your organization. There are no smoke and mirrors here—just hard, cold, empirical evidence provided by independent sources. I also consider some innovative ways Linux on Power will be used in the future.Get the Guide