From: Charles E Campbell Jr <[EMAIL PROTECTED]> Subject: Re: Commenting out TeX-text line by line in V-mode Date: Thu, 16 Nov 2006 13:34:16 -0500
> Meino Christian Cramer wrote: > > > I thought there would be one command to achieve the same effect > > instead of """doing it the wrong way""" first and the """correct > > it""" by an additional command... > > > > > > Well, sure there is. Its Vim, isn't it? ...I hope so... ;O) > How about > > :[range]g/\S/s/^/%/ > > which means: over the selected range (which may be the visual range), > on all lines that > have some non-white-space character on them, insert a leading %. Yeah, that's the kind of trick I was searching for! On the other hand I have still some problems in reading (== understanding), how this is working... [range] ok, I understand that: "upper" and "lower" limit g/ "global"...hrmmm...sometimes I think "g" is a placeholder for: do something differently. As a newbie I cannot predict what "g" does in/for a certain command. The only way for me is: simply remember every single meaning of "g"... \S is for "non-whitespace character" s/^/%/ "substitute the beginning of a line with %". This is simple... For me it is confusing, why we need three "commands" to describe, where something has to be done: First the range, than "global" (I cannot guess why we need "g" here and why it would not work without "g" -- we only want _one_ substitution per line...) and at last \S for all non whitespace. I myself -- based on my current knowledge -- would have never been able to construct such a command on the base of logic. Thank you very much for any enlightment in this case in advance ! "Its Vim, isn't it?"...yes NOW I am sure, it is VIM ;) Keep editing! mcc > Regards, > Chip Campbell