Path: utzoo!utgpu!news-server.csri.toronto.edu!rutgers!mcdchg!chinet!les From: les@chinet.chi.il.us (Leslie Mikesell) Newsgroups: comp.unix.questions Subject: Re: regexp..prepending a line globally (Vi) Keywords: vi, ex, ed Message-ID: <1990Jul3.155941.6037@chinet.chi.il.us> Date: 3 Jul 90 15:59:41 GMT References: <1772@island.uu.net> <3235@d75.UUCP> Organization: Chinet - Public Access UNIX Lines: 34 In article <3235@d75.UUCP> eli@reed.UUCP (Eli Taub/100000) writes: [how to do this in vi]: >>/usr/spool/ftp/comp.sources.unix/volume22/nn6.4: >>part01.Z >>part02.Z >Comments deleted ... >>What I want to end up with is: >>/usr/spool/ftp/comp.sources.unix/volume22/nn6.4/part01.Z >>/usr/spool/ftp/comp.sources.unix/volume22/nn6.4/part02.Z >.... >But since you asked for it ...: >$s/$/^M:/ >g/^.*:$/s @^\(.*\):$@.,/:/-1 s!^!\1/!@ \ >d a \ >*a Good grief! Just edit the first line into the command for the transformation, delete it into a register, and execute the register. This gives you a series of steps you can undo if you mis-type something. edit to: :%s,^,/usr/spool/ftp/comp.sources.unix/volume22/nn6.4/, with the cursor on that line, type "add (delete to register a) then @a (execute register a) if it doesn't look right, just u (undo) "aP (put back from register a) and try again. The only problem to watch for with this approach is that you need an extra level of ^V quoting for any special characters (one to get them into the edit buffer, one to get them into the command). Les Mikesell les@chinet.chi.il.us