The Birth of vi 459
lanc writes "Bill Joy, co-founder of Sun, tells the story of how he wrote the vi editor. The article at The Register delves into his motives, who instigated the project, and some of the quirks of leaving a 'gift to mankind'. From the piece: '9600 baud is faster than you can read. 1200 baud is way slower. So the editor was optimized so that you could edit and feel productive when it was painting slower than you could think. Now that computers are so much faster than you can think, nobody understands this anymore. The people doing Emacs were sitting in labs at MIT with what were essentially fibre-channel links to the host, in contemporary terms. They were working on a PDP-10, which was a huge machine by comparison, with infinitely fast screens. So they could have funny commands with the screen shimmering and all that, and meanwhile, I'm sitting at home in sort of World War II surplus housing at Berkeley with a modem and a terminal that can just barely get the cursor off the bottom line.'"
Re:I've been using vi for so long... (Score:5, Insightful)
Ironically, it doesn't really matter all that much if a command is mnemonic or makes sense in some other way, precisely because, as you say, "they are so ingrained in my brain I don't even remember the actual key sequences."
And from the point of an Emacs user, it doesn't seem so different to need to hit C-X before some commands, than to hit ESC and :.
That said, they're both fantastic text editors. Programmers do their daily work with text, and these two text editors really reward the time you put into learning them. Who cares about a learning curve if this is the sort of tool your career is built around; you need power.
Those who forget history... (Score:5, Insightful)
This is good history to remember. Those who weren't there find it hard to appreciate the tremendous leap forward of Unix Version 6 and ed on a PDP-11. We had been using teco on our PDP-10 and the cousin of ed that was on Multics, but we had been getting into PDP-11s for more and more things. Comparing ed on Unix with the line editors available on PDP-11 DOS/BATCH and that new-fangeled RT-11 thing was amazing. Along with all the other tools available on Unix, the PDP-11 went from a toy to a state-of-the-art (for then) development environment. We were mostly on DECwriters and TI-Silent 700s runing hardwired 1200 baud at work and 300 baud from home over the modems. We started to get VT-100s about the time vi was being released and it was again a great leap forward.
Thanks Bill Joy! I have used your work in the BSDs and Suns and all the followons over the years, but vi was a most important gift at an important time.
Re:Recommended for new *nix users? (Score:5, Insightful)
While emacs, pico etc are installed on most linux systems, you won't find them on Solaris, AIX or HP-UX.
For an end user, they probably shouldn't worry too much as they'll have kedit or something in the GUI, but *nix admins should know vi.
Re:I've been using vi for so long... (Score:1, Insightful)
How horribly untrue. The ESC key is simple to hit. It's in the upper left corner; easy to hit without effort. Control-x is harder to hit because you have to bend your hand down and hit two keys simultaneously. I used to laugh at the many emacs users at my last company because they were always grunting every time they reached for that ^X, often followed by a "damn!" when they hit the wrong key or missed the control.
In vi you only have to hit ESC once to get into command mode. After that you can type commands to your heart's content without the oppression of hitting some hard-to-reach escape sequence every time you want to do something.
Admittedly, once you get used to it, I'm sure emacs is not all that bad. But emacs is just wrong. I want to use an editor to edit my files, not an operating system like emacs.
eek! (Score:2, Insightful)
I prefer Vi, since I spend lots of time at terminals logged into remote machines. Although things are faster these days, having such a tightly optimized editor is useful.
I have taught Emacs. That was an experience that was. I had to spend a week teaching myself how to use it, then teach a bunch of freshly minted undergrads, who then thought I was some kind of Emacs Guru. How wrong they were.
Project students, being slightly more experienced final year bods, were all force marched to the Vi camp (well, gvim, I'm not that cruel), so I wouldn't have to use The Eight Megabytes and Constantly Swapping Monster if they needed help.
Re:So let the flame wars begin! (Score:5, Insightful)
I think the easiest way to sum up Emacs vs Vi is "vi" is for System Admins and people who want to get the job done quickly and efficiently without having to learn Control and Esc commands (if you look "vi" commands they are surprisingly logical compared to "Emacs"), while Emacs is for people who either have dedicated terminals or have a masochistic streak. This is not to say "vi" is better than "Emacs" in fact it is the other way round and if you are prepared to learn it then it is extremely powerful and can make you much more productive. Of course I am generalising but I do remember the first "vi" vs "Emacs" wars.
If you want a graphical editor there is "gvim" or "xEmacs" both great if you have a GUI, however if you are moving between different Unix machines you have to remember that "xEmacs" or even "Emacs" as well as other so called "free" editors may not be installed so that is why most Systems Admins learn "vi" rather than learn "Emacs". Of course if you are a Systems Admin you should at least be aware of how to use "ed" as well.
To sum up. If you like and can use an editor (not just "vi" or "Emacs") productively then go for it.
Now bring on the "car" analogies. Please no "edlin" since you should be marked as "funny" or "troll"!
Hard to learn but worth it (Score:5, Insightful)
Good tools are hard to master.
Re:Too late (Score:5, Insightful)
Re:Too bad vi sucks (Score:4, Insightful)
Insert mode. Overtype mode. That's modal. I suppose you're against that.
Re:Recommended for new *nix users? (Score:3, Insightful)
Re:So let the flame wars begin! (Score:3, Insightful)
vi has an important place. It's installed everywhere (even on embedded systems like Tivo) works the same wherever you are and doesn't require a particularly fast link to work - even today it's easy to be stuck behind dialup.
Re:So let the flame wars begin! (Score:5, Insightful)
Re:So let the flame wars begin! (Score:1, Insightful)
Re:I've been using vi for so long... (Score:4, Insightful)
For anyone who hasn't quite got it yet (the joke, or the approach), once upon a time the Control key was located where the Caps Lock key is now located. How keyboards have changed, mostly for the worse, over the years is an interesting discusssion, but I'll leave that aside for now. The point if you're an emacs user, you need the Control key somewhere handy. If you're a vi user, you need the Escape key handy. By handy, I mean you're not taking your hands off the home keys and reaching for a key that you'll be using every few seconds.
The common approach is simply to remap the Caps Lock key (a mostly stupid and useless key if there ever was one). Doing so is fairly trivial, and works without any sort of ill effect. On *nix systems, there's an example in xmodmap(1). For Windows, there's a utility provided with the various Resource Kits that's called remapkey.exe or something or other. Personally, I think vi is the cat's meow, and to add to that, the Escape key, while a staple of using vi, is also useful in many GUI applications, even on Windows, so it makes perfect sense to remap the key and have it handy.
The real point about vi (and learning vi for those who haven't yet invested the time) is that those same key strokes that you've spent time learning, memorising and eventually reconfiguring to suit yourself can, and typically are, applicable to just about any application out there (Firefox included, though with some trouble). Using set -o vi in bash, for example, can make you feel like you're right at home. On the other hand, those seemingly all-purpose keystrokes don't work everywhere. Editing vi commands within vi aren't possible using vi keystrokes. Another common program is screen, which demands (mostly) a Control key combination entered before any other command. Further info and fun bed time reading is readline(3).
It's worth noting that some vi users don't remap the Escape key, but use the Control-[ combination (which is actually the same as hitting the Escape key). I guess the habit could be learned over time, but personally I find the [ key is a bitch to hit regardless of what keyboard I'm using.
Re:Echoes of the past (Score:3, Insightful)
Web has its own problems. (Score:3, Insightful)
Unless you're doing something AJAX-y, changes do require you to fill out a form and hit "submit", and wait for a response. I don't really see how this is different than editing a config file and pinging the app. But if you're going to do something AJAX-y, we're getting pretty heavy into the realm of external dependencies -- this is no longer something you want embedded into your app, the way CUPS configuration is.
And I don't really want to have to install Apache, mod_ssl, and some AJAX libs just to configure, say, an IRC server, or a DNS server.
Besides: It doesn't have to require pinging the app. I seem to remember exim checking the timestamp on its config file with every mail received, so if you made a change, you could expect it to take effect instantly. Another way to do this would be inotify -- I believe vim writes all your changes to a temporary file, then 'rename's the temporary file on top of the original one. Thus, as soon as you see a new file there, you can probably parse it -- worst case, if you don't trust the text editor, you can wait a second or two for the inotify events to settle.
Now, there are advantages -- you can actually display a finite set of options, you can show the user what their system can actually handle, and there aren't going to be any syntax errors. But none of these have ever really been a problem for me -- I can crack open just about any config file, read the comments, and make a few changes, and be confident that it'll work.
Re:iI like vi (Score:3, Insightful)
Re:So let the flame wars begin! (Score:5, Insightful)
> why the hell do so few apps make use of the Function keys ? It's always Ctrl-
> something.. I'm fine with Ctrl-X and whatnot because they're where my hands
> would sit, but how hard would it be to just alias F1 to Help, F2 to Save, F3
> to Open, in addition to the classic shortcuts..
Pretty damn hard, actually. DOS editors had the advantage of knowing they'd always
be sitting on an IBM-standard PC, with the same scan codes for the functions keys.
But function keys aren't standard. Control-letter codes are. UNIX utilities therefore
have real difficulty with function keys. You have to use termcap/terminfo, and
make sure that it's correctly configured. Control-something will always just work.
Sometimes it is set up for you, and it's always been possible to set it up for
yourself. But most UNIX programmers have never cared that much because most
UNIX programmers are touch typists...and touch typists hate function keys (and
arrow keys, and mice) because they take your fingers off the home keys. Much
better to use ctrl- or alt- codes that don't interrupt your typing.
Chris Mattern
Re:So let the flame wars begin! (Score:1, Insightful)
This goes against the fundamental UNIX philosophy: Many small applications doing a single, simple task. A micro web server is bloat; if you want web configuration, have an external program that does the web configuring.
My experience with those web front ends is that people who don't know what they are doing use them, and end up making a mess of their configuration files. I've seen the state of configuration files after people like this play with their web front ends and call me up, desperate for help because their server no longer works.
The other problem is that those web front ends can have a lot of security problems. One well known offender is cpanel.
Re:Too bad vi sucks (Score:3, Insightful)
Actually it is bad, so bad that Microsoft and a bunch of other keyboard manufactures moved the 'Insert' key which switches between those modes and made it only available via weird Fn-Key combinations. For a lot of people it causes a lot more trouble then worth it and truth to be told, for writing text I have never actually used the mode myself, the only reason when I use it is if I program and have to change some stuff where overwriting is faster then hitting delete or using regex (say multiple lines below each other where a '+' has to be changed to a '-' in only a single column).
Re:So let the flame wars begin! (Score:4, Insightful)
As someone who has been a touch typist for 38 years and a 25=year Unix person, I too find it extremely difficult to accept the claim that the keyboard is necessarily slower than the mouse. That just contradicts my experience. I remember the first time I tried to use a graphical editor - Bravo - the Xerox predecessor to MS Word. It was unbearable. Obviously you didn't need to learn anything by way of commands to do simple editing - just move the mouse and type something to insert, backspace or whatever it was to delete - but I found positioning the mouse precisely to be extremely painful. And this wasn't just due to lack of familiarity with the mouse. In the interim I've used the mouse extensively for some purposes, but I will find it slow and painful to edit documents by positioning the mouse. I usually use Emacs, but occasionally I use Vim, and sometimes I even use ed. I use OpenOffice Writer occasionally for some special purpose, such as creating a sign or poster with really large type or when it is more convenient to use exotic writing systems than it is in TeX. But I don't use it routinely in part because I don't like having to position the mouse. (Another reason is that it seems to start up even more slowly for me than for other people who complain about its slowness. I don't know why that is. It takes FOREVER.)
Before believing in this $50 million worth of research, I would want to know a lot more about what they tested, who, and how. The stated results wouldn't surprise me if the subjects were indifferent typists without much experience with computers or with the software they were using. I would be very surprised if they were true of experienced users. Without the details of the studies, claims like this are simply uninterpretable. Anybody have a link to the actual studies?
Re:I've been using vi for so long... (Score:1, Insightful)
Re:Recommended for new *nix users? (Score:3, Insightful)
Or you've just joined the company and they use the base OS and none of your namby-pamby extra software!
I have yet to see a system build where vi wasn't installed or was removed.