Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!seismo!umcp-cs!chris From: chris@umcp-cs.UUCP (Chris Torek) Newsgroups: net.unix-wizards Subject: Re: VI(1) vs. the world Message-ID: <3772@umcp-cs.UUCP> Date: Thu, 9-Oct-86 08:25:00 EDT Article-I.D.: umcp-cs.3772 Posted: Thu Oct 9 08:25:00 1986 Date-Received: Fri, 10-Oct-86 01:29:10 EDT References: <4327@brl-smoke.ARPA> <357@maynard.UUCP> <113@twg-ap.UUCP> <847@cuuxb.UUCP> Reply-To: chris@umcp-cs.UUCP (Chris Torek) Organization: University of Maryland, Dept. of Computer Sci. Lines: 77 >In article <113@twg-ap.UUCP> narayan@twg-ap.UUCP (Narayan Mohanram) writes: >>How about :g/old-string/s//new-string/gc for conditional replace. Or is >>query replace something different. I was ecstatic when I discovered a `confirm' (or `conditional') suffix to substitute operations in vi. (This was before I ever saw Emacs.) Then I found that its implementation was rather flawed. Vi performs the conditional replace by: 1. Printing the line. 2. Printing `^'s below the matched text. 3. Awaiting confirmation: y or n (others presumably equivalent to `no'). 1. and 2. are ugly---but that is not too bad. 3. sounds fine: type `y' or `n'; if you hit the wrong key, use your back-space key to correct it. Naturally, I soon hit the wrong key. I typed control-H (my backspace; I dislike DEL). Vi echoed ^, H. You *cannot* correct a wrong answer here. Why bother waiting for RETURN then? It would be better, I think, not to wait for RETURN, and to accept only `y', `n', and `q' (quit), and perhaps uppercase versions of these. In article <847@cuuxb.UUCP> mwm@cuuxb.UUCP (Marc W. Mengel) writes: >Not to mention the ":map" and ":map!" commands for keyboard macro's. Maps are tricky. You can do a number of things with maps, but not as much as in Emacs. They do often suffice. >And one volley for the other side: I really like to be able to say >"15j" to go down 15 lines, and "40a -" to be able to make an >80 column dashed line. Does Emacs, (or any other editor, for that >matter) provide this repeat n times facility? (this is not a >rhetorical question, I don't know...) Yes, `but'. To go down 15 lines, type meta-15 (type 15 while holding down the meta key), or ESC 1 5, or control-U 1 5, then control-N. Making a dashed line is more difficult. Vi has a major advantage over Emacs here. In Emacs, you must announce in advance that you intend to repeat something, do the operation, then say it is done; you can then repeat that operation. (This is much like constructing a map, except that you can see what you are doing.) The problem here is that Emacs repeats only single operations. A single operation can, of course, be a `repeat the remembered operations' operation. Vi too repeats only single operations, but vi has a much better indicator as to what constitutes one operation. One operation is everything done from one trip in the `get command' loop to the next. If I type i, f, o, o, SPACE, ESC, vi knows that the last operation was to insert `foo '. Because Emacs is modeless, it does not have this kind of clue. Vi can then repeat the `insert the word foo' operation, either with a repeat count given in advance (`10ifoo') or with a `repeat last command' command (`.........', or `9.'). Emacs's repeat is actually more powerful; it repeats *anything*. There are things you cannot do in vi maps (`put's, e.g., are restricted). But vi's repeat is more convenient, and probably gets used more often. >P.S. A Challenge to those Other Editor users, I can write a vi macro to > reverse the words on a line... can you? I just type meta-control-T in my Emacs. I know rather more than I might wish about both vi and Gosling Emacs. The innards of the latter are considerably cleaner. I believe there are fewer bugs in my (local version of) Emacs than in my (4.3BSD-beta version of) vi. But I use both editors regularly. I pick the one that seems appropriate for the job. -- In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 1516) UUCP: seismo!umcp-cs!chris CSNet: chris@umcp-cs ARPA: chris@mimsy.umd.edu