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:Recommended for new *nix users? (Score:3, Informative)
Re:Too late (Score:2, Informative)
I do. I love to use vi(m) for coding. And it's the only editor I can use efficiently while working remotely. And it's very configurable. And it looks s0 l33t with semi-transparent background and all those beryl effects on my Ubuntu laptop.
But seriously, vi(m) is really great once you learn it. Though I agree it has a pretty steep learning curve. Anyways, it was worth it.
Re:So let the flame wars begin! (Score:0, Informative)
*Note rhetorical question: pfe (programmers file editor) had both power and ease of use many years ago... but unfortunately its not available for *nix.
Re:I've been using vi for so long... (Score:4, Informative)
There's the character level ("C-f"orward, "C-b"ackward), and line level ("C-p"revious line, "C-n"ext line, "C-e"nd of line, "C-a" beginning of line, can't use C-b you see, so might as well use the start of the alphabet). That's when you think of text as rows and columns of characters.
If you think of text as words and paragraphs, then you replace "C"ontrol with "M"eta (which is the Alt key on modern keyboards). "M-f"orward word, "M-b"ackward word, and so on, at least in fundamental mode.
You can also think of text as regions within matching parentheses or other delimiters, then you can use the "M-C" commands (both Meta and Control + some mnemonic key) to move: "M-C-f"orward one expression, "M-C-b"ackward one expression, etc.
What makes all this powerful is that emacs can recognize what kind of file you're editing, then it chooses good defaults for the various levels. So if you're programming in C, when moving around one word at a time, emacs doesn't get confused by the punctuation, and if you like to use something like CamelCase, then there's a minor mode which changes for "M-f"orward and "M-b"ackward word commands so the cursor stops before each hump inside an identifier instead of jumping to the next word.
Unfortunately, emacs has so many commands that there's not enough keys on a keyboard to have simple mnemonics for all the things it can do. That's why we get things like "C-c C-o C-1" in esoteric modes. But if you use specialized modes, the idea is that you should select a key that you like and map the function to it. Usually, the functions keys F1-F12 are completely free to use for anything.
Re:Too late (Score:2, Informative)
Interesting Choice of News (Score:5, Informative)
Re:How do I go about learning Emac? (Score:3, Informative)
Trolling for controversy? (Score:2, Informative)
Re:So let the flame wars begin! (Score:4, Informative)
Re:So let the flame wars begin! (Score:4, Informative)
"vi"'s defaults are completely oriented towards editing large text config files - better than ANY other editor I've ever seen. emacs often defaults to scrolling past the end of the screen (where you can miss important info if you're not careful). Other editors auto line wrap, or don't properly handle control or windows characters (vi shows nice ^M or whatever symbols). Search-and-replace is fast, and extremely expressive (moreso than any windowed dialog I've ever seen, including [xg]emacs). These are the tools of the sys-admin.
That being said. Remote server management is best "designed" to use a web interface. Any shmuck can design an application that has a foo.properties or foo.conf or
The only remaining elements are buffer-overrun exploits, DOS attacks, authentication... In the UNIX world, you have to be root to edit the config file, so that was considered secure enough. But apache port-80 proxying is commonplace now.. You get all your security up-front. Granted the flaw in my argument is that apache doesn't have web configuration - and probably never will.
Every home-use NAT-box / router I've seen has http interfaces, and that's just dandy for me.
Re:parentheses and brackets, oh yeah (Score:3, Informative)
Or 10Gma2jd'a Goto line 10, mark line/col-number to buffer a, move down j 2 lines. d from current line to marked line a
Or 02wma2j01wd`a Go to 0'th column of current line. Jump 2 words forward. mark line/col to buffer a. Jump 2 lines j (down). Go to 0'th column. Jump 1 wword forward. delete from the `current line/col to the line col in buffer
Cryptic, but no more so than a programming language - once you learn the building blocks, complex stuff comes naturally (assuming you have a mind for compositing).
I've not see named buffering (especially with the ability to refer to either the lines as a whole or the exact col-positions) in any other editor. emacs has ring-buffers (or kill-buffers), but I've never been able to use that intuitively. There are vi key-sequences that can be applied to heavy-weight editors like emacs, eclipse or Intellij Idea, but they just don't seem to fit naturally (because the power of those editors are afforded by their special key-sequences).
The end result is that I still have gvim windows and Idea windows on separate monitors 24/7. Each type of editor does its intended role perfectly - no more, no less.
Re:So let the flame wars begin! (Score:3, Informative)
> ancient [...] relics with arcane "interfaces".
Nobody, so far as I am aware, uses Emacs because of its default interface (which is, indeed, ancient and arcane). We use it because of its capabilities, and we customize the interface to suit our needs. Yes, there are people who *use* the default interface, because they are accustomed to it, because they needed Emacs for its features and never bothered to customize the interface. But they don't use Emacs *because* of the interface.
> Sure, *nix geeks will love it, and they may even devout a surprisingly pathetic
> amount of time mastering it because, "technically speaking, it provides a much
> more robust set of features than any GUI-based program."
You clearly don't understand Emacs.
In the first place, it *is* a GUI-based program. (Yes, you can run it without a GUI, but you would only ever do so if for some reason no GUI is available, and certain features become unavailable under such circumstances; it is certainly not the normal mode of operation.) Second, the amount of time it can save you on a day-to-day basis over a normal text editor editor will pay back your initial learning-time investment in a few weeks, or at most a few months -- at least, it will if you are doing the kind of editing Emacs was designed for.
Emacs is very good for partially automating semi-repetitive tasks. Some tasks can be fully automated, and that's fine, but many editing tasks cannot be automated in that fashion, because the user to constantly make decisions that the software can't handle. Yes, you *could* write an application in Perl or some other language that would repeatedly ask you questions about what to do, but writing it would be tedious and using it would be worse. Emacs, because it embeds and fully integrates the programming language into the text editor, solves these problems much more quickly and easily.
Of course, if you don't perform the kind of editing tasks that Emacs is really good for, then you probably don't care. And if you aren't already a programmer, then learning lisp would be much harder (because you'd have to learn all the programming concepts, in addition to the language) and maybe not worth it. But that doesn't make it any less a valuable tool for those who need it.
A more modern default interface wouldn't hurt it any, I'll grant you. But there is no alternative, currently. There is no tool that can do the things Emacs does, with the ease with which Emacs does them, and has a modern user-friendly default interface. Emacs is the only game in town.
Sure, there are many text-editors. But there are not many *fully* programmable integrated text editing environments -- at least, none that I'm aware of.
Learning to use a bandsaw is a silly waste of time if all you're going to do with it is sharpen pencils. An ordinary pencil sharpener is much easier to learn to use properly, takes up less space, is less dangerous, and will sharpen the pencil just about as quickly. Fine, use the pencil sharpener. But people who make dollhouse furniture are probably going to opt for the bandsaw.
Re:So let the flame wars begin! (Score:5, Informative)
Plus you can use vi or emacs in situations where you don't have a GUI available, or on boxes where there isn't much memory to spare, and you'd rather the resources went to GCC than to an X-Server.
Re:I wish I had portable vi (Score:2, Informative)
Re:Join the Church of vi (Score:3, Informative)
I call BS! On Bill Joy!?! (Score:4, Informative)
I remember once getting really fooled by this. I'd accidently created a file with two sequential copies of the text I thought I had. I searched for "foobar", which worked as expected; then I searched again. The screen didn't change, and the cursor didn't move. So, first I checked if the mainframe had crashed, but that wasn't it. It took many minutes of fooling around to realize what had happened: EMACS had figured out that the screen already looked right, so no need to do anything (except perhaps update a character or two on the status line). I wonder how many other people had similar experiences back in the day.
So, sure EMACS may have been too big to run fast on Bill's machine, but bandwidth to the terminal had nothing to do with it.
Re:So let the flame wars begin! (Score:3, Informative)
Re:So let the flame wars begin! (Score:4, Informative)
Modality, and special keys (Score:4, Informative)
One can edit in VI very efficiently without moving the keys from the home position, and doing unnatural stretches for odd keys.
Re:So let the flame wars begin! (Score:2, Informative)
Re:So let the flame wars begin! (Score:3, Informative)
Of course, it would help a lot of we had a bit more breakdown on the test subjects, say by computer experience and familiarity with GUIs. For all we know, the power user segment may have consistently beaten the stopwatch on keyboards, bit overall the mouse wins because they tested more naive users. I'd guess that's what they did, because OS developers put such a high priority on newbie-friendliness
We should also bear in mind that the article discusses multi-application usage in an environment where the hotkeys are acknowledged to be inconsistent and illogical. In fact the author even admits that the keyboard would be faster, except that the user takes as long to remember what the hotkeys are for a given app as it does the mouse user to switch to mouse and back. So for a single application task such as editing, or an environment with sensibly defined hotkeys there's every reason to believe that the conclusions don't hold up
But the most important point is this one: I don't know if you intended this link as a rebuttal, but it seems the authority you cite actually agrees with me.
Re:pico -w (Score:3, Informative)
Re:Too bad vi sucks (Score:1, Informative)
It's all in how your mind works. I have been using vi for about 23 years now, and I don't even think about it. I'm very happy and productive in vi.
Personally, I'd rather bang on the Esc key with a pinky once, and then be in edit mode, rather than having to mash the control key while typing Ctrl+X Ctrl+C or whatever. You don't have to agree with me; we can both run what we prefer, no big deal.
In short I simply don't get how to use Vi the Right Way[tm], since it works completly different then I work and think.
If true, then you shouldn't use vi. And that's okay.
I have never meet anybody who either could show or explain to me how to actually use Vi
I think of vi as the text editor equivalent of a set of Lego blocks. You have a few small commands, which "snap" together into bigger commands.
w moves forward a word.
dw deletes forward a word.
fi skips the cursor to the next 'i' character in a line.
dfi deletes forward to the next 'i' character in a line.
I totally love being able, in one step, to delete from the cursor to the next 'i' character. And what if there were two 'i' characters in the middle of the text I want to delete, before the final 'i' character I actually want to delete? Well, you can count them and use d3fi, or you could use dfi and then bang on the '.' key twice (the '.' repeats the last command).
There are basics: move forward word, move to end of line, etc.
There are shortcuts: move to end of line is $, so delete to end of line is d$, but since that's common you can just hit D.
There are advanced shortcuts.
And there is ex mode (available with the ':' key) if you want it too.
Begin able to delete the next 5 lines, sentences, paragraphs or whatever via a simple two letter command sounds nifty in theory, but I have yet to meet any real world example where that actually would be useful, I mean how am I supposed to know that it are exactly five lines and not six, or ten and not eleven? Am I supposed to count them by hand on the screen?
Well, if you want to. But usually I use the mark command: mb assigns mark 'b' to the current position. Then you can navigate to the end, and:
'b would return to the marked position called 'b'
d'b deletes back to the marked position called 'b'
Sometimes I mark beginning with mb, then mark end with me, then use the ex command:
If I can just look and see that I have, say, 3 lines to delete, I'll just bang out 3dd. But for longer ones, I use the marks.
Maybe its time for somebody to just place a camera above his shoulder and show some of the mighty power of Vi in real life and upload the result to Youtube,
Huh. Interesting idea. Maybe I'll do that sometime.
I'm fast with vi, and I doubt I'll ever be as fast in any other editor. I can chop out a block of code, move around, paste it in, shift it over, etc etc all without thinking about what I'm doing. My fingers understand vi, I don't think "3dd", I just think about the three lines going away and they do. It's wonderful. But I don't try to claim everyone would agree with me.
Re:I've been using vi for so long... (Score:2, Informative)
Re:So let the flame wars begin! (Score:3, Informative)