Date: Thu, 2 Nov 2000 22:25:51 +0000 From: Mark Ovens <marko@freebsd.org> To: David Talkington <dtalk@prairienet.org> Cc: freebsd-questions@freebsd.org Subject: Re: vi question Message-ID: <20001102222551.A254@parish> In-Reply-To: <Pine.LNX.4.21.0011012139110.2831-100000@sherman.spotnet>; from dtalk@prairienet.org on Wed, Nov 01, 2000 at 09:45:17PM -0600 References: <Pine.BSF.4.10.10011011629320.67270-100000@andrsn.stanford.edu> <Pine.LNX.4.21.0011012139110.2831-100000@sherman.spotnet>
next in thread | previous in thread | raw e-mail | index | archive | help
On Wed, Nov 01, 2000 at 09:45:17PM -0600, David Talkington wrote: > -----BEGIN PGP SIGNED MESSAGE----- > > > [Perhaps off-topic, I'm sorry ...] > > Now, that's interesting. Forgive my ignorance, but what is that > "substitution" really doing? It's my understanding that the > start-of-line meta represents a position (immediately left of the > first character in the line), and not an actual character ... which > suggests that it can be located as an anchor, but not removed or > altered. Obviously, the start of the line isn't "replaced" in this > case ... is this just a funky way to fool the regex (e.g. unexpected, > but useful, behavior)? > It's a kind of shorthand. Just using ``^'' (which as you quite rightly state is an anchor) is equivalent to: :7,17s/^\(.*\)/#\1/ i.e. replace anything at the start of the line with #anything HTH > - -d > > - -- > David Talkington > Community Networking Initiative > dtalk@prairienet.org > 217-244-1962 > > PGP key: http://www.prairienet.org/~dtalk/dt000823.asc > > Annelise Anderson wrote: > > >There are two ways I know of to comment a block of lines in vi. > > > >1) Turn on line numbering with :se nu ; the do: > > > >:7,17s/^/#/ > > > >This puts a # at the beginning of lines 7 through 17. > > > >2) Put cursor on line where you want to start the substitution > >do this: > > > >:.,+10s/^/#/ > > > >That starts at the line you're on (the .) and for that line and > >the next 10 lines (11 total) places a # at the beginning of the line. > >This is especially useful in editing a kernel config file. > > > >Annelise > > > > > >On Wed, 1 Nov 2000 8773836928@skytel.com wrote: > > > >> Hello, > >> > >> I have been editing some > >> Perl scripts in vi recently, > >> and I find it very annoying > >> that Perl cannot comment > >> blocks of code, only lines. > >> > >> I have been reading the docs in vi, but I can't quite figure out how > >to do a substitute command that will, say, prepend a # to the > >next n lines, and later remove the # ( well, the second one > >I could always use :s and replace the first # with nothing > >for the next n lines. But the first one is still a mystery to me ). > >> > >> Any insight would be greatly appreciated. > >> > >> Thanks! > >> > >> P.S. Please cc: me, as I am not subscribed to the list with this account. Thanks again. > >> > >> > >> To Unsubscribe: send mail to majordomo@FreeBSD.org > >> with "unsubscribe freebsd-questions" in the body of the message > >> > > > > > > > >To Unsubscribe: send mail to majordomo@FreeBSD.org > >with "unsubscribe freebsd-questions" in the body of the message > > > > -----BEGIN PGP SIGNATURE----- > Version: PGP 6.5.8 > Comment: Made with pgp4pine 1.75-6 > > iQEVAwUBOgDjUr1ZYOtSwT+tAQF1TQf/Uany60BTGmAQgqhILuMHH+3WZt/JlMPi > ZzzYucDAIf0T8x3G3UljU0uQnhSJmqbVaUwHBk50HE76B7b2ieK0AC0IQ84mC4SQ > z22pR9lkQ5akjnTJ5zcvRsc39GNiI68InvcqfUAfy5cTLIJ8j8oNd5fJjH96LMML > Wg0w4LMHnMGVxMXt4o8fVqg26b6oL7zP0lvez+BfwoOp9BzLgHr2O5Wf/YViISUC > U+uo3iFuTsxO4+5qQ2BvCZ1pLQSMYy49fQ5tvhpDscg02ev+LXSdwCx6422Z3hZf > Br2xFjKbe6aGbm26wSSt8xx+zsLYqSmrWfvlE4k3cIIZ8x7C33Bvjw== > =TASF > -----END PGP SIGNATURE----- > > > > > To Unsubscribe: send mail to majordomo@FreeBSD.org > with "unsubscribe freebsd-questions" in the body of the message -- 4.4 - The number of the Beastie ________________________________________________________________ 51.44°N FreeBSD - The Power To Serve http://www.freebsd.org 2.057°W My Webpage http://ukug.uk.freebsd.org/~mark mailto:marko@freebsd.org http://www.radan.com To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20001102222551.A254>