Trying to eliminate superfluous <CR>s

Any questions involving matching text strings to patterns - the pattern is called a "regular expression."

Moderator: General Moderators

Post Reply
User avatar
ReverendDexter
Forum Contributor
Posts: 193
Joined: Tue May 29, 2007 1:26 pm
Location: Chico, CA

Trying to eliminate superfluous <CR>s

Post by ReverendDexter »

Okay, I'm hoping that I just missed this with the search, but it's driving me nuts and my only alternative is to do this by hand.

I'm trying to get rid of some extra carriage returns in some text. Basically, I have some html <ul><li>Items</li>....</ul>, and right now there's a return (and space) between every item, specifically between the previous </li> and the next <li>.

I've tried

Code: Select all

:%s/>^M </></g
:%s/>^M </></m
:%s/>^M </></mg
and variations that escape the '<' and '>', and every which way I do it, I get an E488: Trailing Characters

Someone wanna beat me with the clue stick?
User avatar
ReverendDexter
Forum Contributor
Posts: 193
Joined: Tue May 29, 2007 1:26 pm
Location: Chico, CA

Post by ReverendDexter »

So I ended up doing this by hand, I did a search for ">$", and then hitting nJx (next match, join lines, del char) about 300 times.

I really don't want to have to do it that way in the future.... no one has any ideas?
User avatar
Benjamin
Site Administrator
Posts: 6935
Joined: Sun May 19, 2002 10:24 pm

Post by Benjamin »

I'd probably just write a quick PHP script to get rid of them if I absolutely had to.
User avatar
ReverendDexter
Forum Contributor
Posts: 193
Joined: Tue May 29, 2007 1:26 pm
Location: Chico, CA

Post by ReverendDexter »

Yeah, that's what I'll probably end up doing if I have to do it again, but I know this is possible with the regex in Vim, and it bugs me that I can't figure it out there.
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

In Dreamweaver you can do a find all and replace :wink:
Post Reply