Carl Lowenstein wrote:
On Jan 25, 2008 2:40 PM, James G. Sack (jim) <[EMAIL PROTECTED]> wrote:
Carl Lowenstein wrote:
On Jan 25, 2008 1:58 PM, Ralph Shumaker <[EMAIL PROTECTED]> wrote:
I know the vim command :%s///gc to replace throughout the file, with
verification, including multiple occurrences on individual lines.  But
I'm not quite sure how to go about what I want.

I want to issue the command such that any lines that are not ^$$
(BOL$EOL) or ^%$ will get <br> appended *unless* the line already ends
<br>$ (<br>EOL).

I think I understand that sometimes when you write "$" you mean the
dollar-sign character and other times you mean the symbolic
representation of End-Of-Line.  But it is not completely clear.

I was afraid it may have been confusing to anyone but me. That's why I gave the example of the file contents.

Perhaps the command you are looking for is "g!" global exclude.

:%g!/pattern/action             # perform action on all lines not
matching pattern
                                       # action can include another
substitution match
                                       #  and other specifications
like g)lobal and c)onfirm
:%g!/pattern/s/pattern2/new thing/gc
Wow another vim capability I never encountered.

Now, I wonder if there is any way to get more occurrences of the adj/adv
 "global" into a vim command. This one has 3 does it not?


There are only two.  The first g is "global within the specified
range", the second one is "global within the line".  Vi/Ex have been
like this since forever.  Actually I find this usage in 6th Edition
Unix ed(I) dated 1973.  So blame it on Ken Thompson not Bill Joy.

Well, OK the "%" also states that the specified range is the whole file.

    carl

I had to fuss with it a little, but ended up with:
:%g!/<br>$\|^[$%]$/s/$/<br>/gc

That worked perfectly. And with command history, I don't even have to re-type it.

What I tried first was:
:%g!/<br>$/g!/^[$%]$/s/$/<br>/gc

Apparently, you can't use the g! twice (or I didn't format it right).

Thanks carl



--
Ralph

--------------------
It is better to keep your mouth shut and appear stupid than to open it and remove all doubt.
--Mark Twain


--
[email protected]
http://www.kernel-panic.org/cgi-bin/mailman/listinfo/kplug-list

Reply via email to