Slashdot Mirror


The Birth of vi

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.'"

25 of 459 comments (clear)

  1. Re:Recommended for new *nix users? by menkhaura · · Score: 2, Informative

    I usually walk them through gvim, and slowly introduce the keyboard commands. If the person isn't a doorknob, she will learn at least keyboard navigation and basic search and replace in no time. Besides, with syntax highlighting, auto-indenting, multiple (split) views on the same window (which OpenOffice to this day can't do) and other goodies make me want nothing but vim, even when I'm on a Microsoft platform.

    --
    Stupidity is an equal opportunity striker.
    Fellow slashdotter Bill Dog
  2. Re:Too late by robzon · · Score: 2, Informative

    Who really uses either editor these days?
    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.
  3. Re:So let the flame wars begin! by Anonymous Coward · · Score: 0, Informative

    Agree that they're both ordinary. I'm still looking for a semi-decent editor for linux. vi is just god-awful to use. Emacs is just as bad despite looking "nicer". pico and nano leave me cold. They're an improvement over vi and emacs, but still fall somewhere short of even the old dos editor in terms of usefulness. Indeed, of all the (many) editors I've tried nedit is the nicest... but is buggy as hell (at least on my ubuntu install). Why oh why can't an editor have both power and ease of use?*

    *Note rhetorical question: pfe (programmers file editor) had both power and ease of use many years ago... but unfortunately its not available for *nix.

  4. Re:I've been using vi for so long... by martin-boundary · · Score: 3, Informative
    The Emacs command set is mnemonic as well ("mnemonic" here means that keystrokes are designed to be easy to remember). The basic Emacs commands exist on several logical levels.

    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.

  5. Re:Too late by mwanaheri · · Score: 2, Informative

    I use it. Vi (or better: vim) is really sweet if you have to look at textfiles of >100mb. Also, if you have to edit a file on a different machine. On the other hand, when working in a graphical environment anyway or as a suggestion to new users, I often recommend kate.

    --
    Idha khatabahum lijahiluna qalu salaman
  6. Interesting Choice of News by icedivr · · Score: 5, Informative

    The article has definately triggered some nostalgic moments, but it's an article from September 2003 that reports on the content of an interview conducted in 1999. It isn't really news any longer.

  7. Re:How do I go about learning Emac? by Marcos+Eliziario · · Score: 2, Informative

    "And why do they teach the letter commands to go through the program when the up, down, left, right arrows exist on every keyboard and do the job?" They do. But they do require more movement from your hand. Believe me, once the commands for navigating thru text are impregnated in your brain, you'll crave for them even within Microsoft Word. At that point of addiction, you'll start googling "emacs key binding microsoft word"

    --
    Your ad could be here!
  8. Trolling for controversy? by hammarlund · · Score: 2, Informative

    Interesting article, but this article was published on 11th September 2003.

  9. Re:So let the flame wars begin! by Anonymous Coward · · Score: 4, Informative

    XEmacs isn't the X version of Emacs - it's a completely separate fork.

  10. Re:So let the flame wars begin! by maraist · · Score: 3, Informative

    First, I am totally with you - vi is a MUST for configuring UNIX servers remotely (or even locally) (I want to shoot our sysadmin when he uses nano or pico and "accidently" line-wraps a critical config item).

    "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 .foo But for all the effort that goes into writing the configuration API, you might as well embed a micro-web server (there is no language known to man that can't receive a trivial text input, reading only the 1'st line, and spitting out a canned text). It is just as easy (if not easier) to add configuration line-items via a web-form than via a config-file. The reason being, that changes to a properties file usually require restarting or pinging the core app. The micro-web service is directly updating the active operation (and can take whatever steps necessary to perform batch alterations.

    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.

    --
    -Michael
  11. Re:parentheses and brackets, oh yeah by maraist · · Score: 2, Informative

    Come on.. You haven't memorized "aYj"bY2j"ap2j"bp yet? (" (Store next-command in buffer) a, Yank-line. j Move to next line. " (buffer) name b Yank line. (Repeat next command) 2 times - j line-down. Then from " (buffer) name a paste. 2 lines j (down), From " (buffer) b, paste.). Once you've written that to your brain, the ability to cut and past between hundreds of megabytes of text file becomes blinding.

    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.

    --
    -Michael
  12. Re:So let the flame wars begin! by jonadab · · Score: 3, Informative

    > I was going to say the best way to sum them up is that they are both
    > 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.

    --
    Cut that out, or I will ship you to Norilsk in a box.
  13. Re:So let the flame wars begin! by NickFortune · · Score: 4, Informative
    why would you learn any of those? At all? Most people today, including most computer people, don't seem to share your belief that it's evil to place your hand on the mouse.
    Because they're faster. Just like it's faster to use Control+S to save a document than it is to use the mouse to open the file menu, position the pointer over the save entry and press the button.

    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.
    --
    Don't let THEM immanentize the Eschaton!
  14. Re:I wish I had portable vi by dyamkovoy · · Score: 2, Informative

    There _is_ a portable gVim here. And for built in vi, Firefox has the ViewSourceWith plugin, which works just great with gVim. It lets you edit any textarea using the editor of your choice. (I'm not affiliated with either of these, they're just good software.)

  15. Re:Join the Church of vi by cananian · · Score: 2, Informative

    That's what CafePress is for.

    --
    [ /. is too noisy already -- who needs a .sig? ]
  16. I call BS! On Bill Joy!?! by drfuchs · · Score: 4, Informative
    Sorry, Bill, but your memory has dropped a few bits. Even back in the 1970's, EMACS was very careful about doing only the absolute necessary screen updating, and worked quite well at 1200 baud. The code made all sorts of effort to take advantage of whatever capabilities your particular terminal had for moving text around on the screen by itself (such as inserting a character within a line without re-sending the whole line; ditto for inserting a new line without having to re-send the lines below it). See "The Display Processor" section of Stallman's "EMACS: The Extensible, Customizable Display Editor" 1981 paper for the ACM Conference on Text Processing http://www.gnu.org/software/emacs/emacs-paper.html / for more info on the optimizations involved.

    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.

  17. Re:So let the flame wars begin! by AlbertEin · · Score: 3, Informative

    (there is no language known to man that can't receive a trivial text input, reading only the 1'st line, and spitting out a canned text) Oviously you haven't used Malbolge
  18. Re:So let the flame wars begin! by kasparov · · Score: 3, Informative

    Or more likely 'joe' is a reference to joe, Joe's Own Editor, which has been around since the late eighties. In fact I used it exclusively back when Slackware was distributed on floppies--my temp files were always named bob so I could type 'joe bob' to edit them. Of course this was before I "did the right thing" and switched to vi. :-)

    --
    There's no place I can be, since I found Serenity.
  19. Modality, and special keys by PhotoGuy · · Score: 3, Informative
    One thing Joy didn't mention, but I think is probably safe to imply, and one of the reasons that vi is still my favorite editor: because of its modes, you don't have to rely upon special keys (arrows, function keys, etc.), because the navigation is done with the standard alphanumeric keys (which the typewriter keyboard was designed for, not for taking the hands off the home position to reach for arrow keys and such).

    One can edit in VI very efficiently without moving the keys from the home position, and doing unnatural stretches for odd keys.

    --
    Love many, trust a few, do harm to none.
  20. Re:So let the flame wars begin! by psy0rz · · Score: 2, Informative

    You might want to try mcedit, for that oldskool dos-edit feeling.:) (part of midnight commander)

  21. Re:So let the flame wars begin! by NickFortune · · Score: 2, Informative
    Cool. Interesting article.

    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:

    Not that any of the above True Facts will stop the religious wars. And, in fact, I find myself on the opposite side in at least one instance, namely editing. By using Command X, C, and V, the user can select with one hand and act with the other. Two-handed input. Two-handed input can result in solid productivity gains (Buxton 1986).
    I don't know if you intended this link as a rebuttal, but it seems the authority you cite actually agrees with me.
    --
    Don't let THEM immanentize the Eschaton!
  22. Re:pico -w by hawaiian717 · · Score: 2, Informative

    alias nano="nano -w" is found in most of my .bashrc files. You can also add set nowrap to /etc/nanorc or ~/.nanorc. I just noticed that option today.

    --
    End of Line.
  23. Re:Too bad vi sucks by Anonymous Coward · · Score: 1, Informative

    In the strict sense inputing means straight forward typing, no backspace, no cursor movement no nothing, just text from left to right, all those other stuff is reserved for the edit-mode. That however is totally not how I or anybody I know works. I constantly jump around, insert a bit here, a bit there, go a few words forward or backwards, mark and delete a little here and there. Switching modes between each and every of these operations, which just take a few second or less, is totally annoying

    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: :'b,'ed<Enter>

    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.

  24. Re:I've been using vi for so long... by thogard · · Score: 2, Informative

    Where does the :wq come from? It was superseded decades with the introduction of :x which gets rid of the ambiguity of :wq! meaning :w!q or :w q!

  25. Re:So let the flame wars begin! by Antique+Geekmeister · · Score: 2, Informative

    Then I suggest you take a close look at the copyrights on Washington University's Pine and its included Pico editor. They do not permit people to modify and rebundle the software, even simply for packaging purposes, without written permission. That's why it's no longer found in most distributions. There are better tools with better support of features like Maildir and better integration with local IMAP servers, and without the nasty copyright history.