Path: utzoo!censor!geac!torsqnt!news-server.csri.toronto.edu!cs.utexas.edu!usc!apple!olivea!oliveb!felix!asylvain From: asylvain@felix.UUCP (Alvin "the Chipmunk" Sylvain) Newsgroups: comp.editors Subject: Re: vi delete to # Message-ID: <154293@felix.UUCP> Date: 28 Nov 90 20:00:23 GMT References: <1990Nov21.025246.8298@mthvax.cs.miami.edu> Sender: daemon@felix.UUCP Reply-To: asylvain@felix.UUCP (Alvin "the Chipmunk" Sylvain) Distribution: na Organization: FileNet Corp., Costa Mesa, CA Lines: 48 In article <1990Nov21.025246.8298@mthvax.cs.miami.edu> wb8foz@mthvax.cs.miami.edu (David Lesher) writes: > I'm looking for a macro that would delete to a given line > number. For example: You are editing a file, and are on line 5. > You want to delete everything up to line 17. Now of course, you > can subtract in your head, and use a 12dd. But my view has always > computers are supposed to do those things for me! > > Any suggestion on a "delete to {or delete through} line #" macro? I do this all the time. I put the cursor on the first(last) line I want deleted, then enter :.= which tells me the line number there. Then I put the cursor on the last(first) line, and enter :N,.d (:.,Nd) where `N' was the previous line number (determined by the `:.=' command). The `.' indicates current line number. Don't forget, "vi" is not really a "screen" editor. It is actually a "screen" interface on top of "ex", which is a "line" editor. When you enter the `:' you are entering an "ex" command directly. This allows you a number of convenient options, such as :.,.+4w! temp which writes to a file named "temp" (overwriting if needed) the 5 lines beginning at the current cursor position. This breaks down as follows: : - go to "ex" mode . - current cursor position , - thru ... .+4 - current cursor position plus 4 w - write ! - I really mean it! overwrite if necessary (default no overwrite) temp - name of the file to create (defaults to original filename) :-) note that this is a smiley face, not an "ex" command. -- asylvain@felix.UUCP (Alvin "the Chipmunk" Sylvain) ========================= Opinions are Mine, Typos belong to /usr/ucb/vi "We're sorry, but the reality you have dialed is no longer in service. Please check the value of pi, or see your SysOp for assistance." .hplabs!felix!asylvain ================================================ Brought to you by Super Global Mega Corp .com