Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!uunet!samsung!think.com!mintaka!bloom-beacon!eru!hagbard!sunic!mcsun!cernvax!chx400!bernina!neptune!inf.ethz.ch!wyle From: wyle@inf.ethz.ch (Mitchell Wyle) Newsgroups: comp.editors Subject: Re: vi for power users Message-ID: <17723@neptune.inf.ethz.ch> Date: 10 Dec 90 14:00:15 GMT References: <109909@convex.convex.com> <1990Dec08.200418.6663@chinet.chi.il.us> <110093@convex.convex.com> <1990Dec10.051430.12025@chinet.chi.il.us> Sender: news@neptune.inf.ethz.ch Reply-To: wyle@inf.ethz.ch (Mitchell Wyle) Organization: Departement Informatik, ETH, Zurich Lines: 133 In <1990Dec10.051430.12025@chinet.chi.il.us> les@chinet.chi.il.us (Leslie Mikesell) clarifies: >Actually, I do have fmt on at least one of the machines, but I routinely >log into and edit files on many machine where I don't maintain the >programs. Some of them don't even have compilers. I don't mind carting >my .profile and perhaps an .exrc around, but having to install new programs >just to reformat a paragraph is a bit much. and the fmt from uunet has BSD-isms in it, making it hard to port. Face it, Tom. If you EDIT prose, you need a fmt function in your text editor. The lisp and magic stuff are not so important, especially if you don't edit lisp! But the lack of fmt is a glaring hole in vi. >>>2) How do you manipulate arbitrary rectangles of text (copy/delete/move)? > >>No, that's not built-in to the program. What's the application? If you >>just want to swap or delete fields or columns around on the same lines, >>you could easily do it from within vi itself. (Although it might be more >>conveniently expressed using a more general-purpose tool.) Just because >>everything is built-in to a PC program doesn't mean you should do it that >>way in UNIX. > >If you don't build it in, you are going to have a heck of a time figuring >out the piece you want to manipulate in the other tool. > >>The very *VERY* few times I've wanted to do something not on >>the same line, it takes me maybe 15 seconds of programming in sed, cut, >>awk, or perl does the trick. Show me the kind of problem you mean. > >It's a situation you would see in secretarial work more than programming. >You have something typed in with nice alligned columns and at the last >minute you decide to move one of the columns. Happens all the time. >In programming, the only time you would see something like this would >be in a list that initializes an array of structs, if you had gone >to the trouble of visually alligning the elements in the first place. >In practice, I don't need this a lot myself but it is a very good reason >not to recommend vi for secretarial use. Tables: 1. Don't use vi to do tables; use sc(1). 2. If you have violated rule 1, you must resort to the regular-expression stuff in the right-hand-side of a substitute (:s) command, or else bang in the sed or awk script. In this case, given something like: 1 2 3 4 5 6 7 8 9 10 12 113 18 1012 11 1 2 3 4 5 6 7 8 9 10 12 113 18 1012 11 1 2 3 4 5 6 7 8 9 10 1 2 3 4 5 6 7 8 9 10 12 113 18 1012 11 a b c d e f g 12 113 18 1012 11 a b c d e f g 6 7 8 9 10 12 113 18 1012 11 a b c d e f g To get the columns in a different order, you could type a vi command like: !}awk '{print $3 " " $2 " " $1 " " $4 " " $5}' 3 2 1 4 5 8 7 6 9 10 18 113 12 1012 11 3 2 1 4 5 8 7 6 9 10 18 113 12 1012 11 3 2 1 4 5 8 7 6 9 10 3 2 1 4 5 8 7 6 9 10 18 113 12 1012 11 c b a d e 18 113 12 1012 11 c b a d e 8 7 6 9 10 18 113 12 1012 11 c b a d e You can make the table look nicer with the vi command: !}halign r r r r r which gives us: 3 2 1 4 5 8 7 6 9 10 18 113 12 1012 11 3 2 1 4 5 8 7 6 9 10 18 113 12 1012 11 3 2 1 4 5 8 7 6 9 10 3 2 1 4 5 8 7 6 9 10 18 113 12 1012 11 c b a d e 18 113 12 1012 11 c b a d e 8 7 6 9 10 18 113 12 1012 11 c b a d e and don't forget !}sort 3 2 1 4 5 3 2 1 4 5 3 2 1 4 5 3 2 1 4 5 8 7 6 9 10 8 7 6 9 10 8 7 6 9 10 8 7 6 9 10 8 7 6 9 10 c b a d e c b a d e 18 113 12 1012 11 18 113 12 1012 11 18 113 12 1012 11 18 113 12 1012 11 18 113 12 1012 11 fun, eh?