On 14/12/08 02:57, Robert Mark Bram wrote:
> Thanks Tim,
>
>>> :%s/\(<\/\+p>\)/^M\1^M/g
>>> Simply, it is only replacing the first instance on each line.. can
>> thanks to your \+ requiring one or more "/" characters.  I
>> suspect you may be wanting \= instead.
>
> It was that.. plus I had this setting in my .vimrc:
>
> " assume the /g flag on :s substitutions to replace all matches in a
> line:
> set gdefault

Yeah, I set that at one time in the past but I came back from it.

>
>
> So all I needed was this:
> :%s/\(<\/\=p>\)/^M\1^M/
>
>> Alternatively, if you have literal "caret capital-M", instead of
>> a literal control+M (as entered with "control+V control-M), you
>> might use "\r" instead of the "^M".
>
> Btw, I mad the ^M with control+V, ENTER. I thought that was the (a?)
> correct way to get a new line character in the replace section of a
> sed.

It is one correct way, but neither the simplest nor the easiest (in Vim, 
I'm not talking about sed, which I haven't really studied yet). In the 
replace-by part of a ":s[ubstitute]" command, \r breaks the line (but in 
a search pattern, or in the replace-what? part, \n finds a linebreak). 
In a ":map" command (or one of its variants), <CR> (4 characters) 
corresponds to a press on the Enter key (reacts to it in the {lhs}, or 
simulates it in the {rhs}). In a double-quoted string, "\r" represents a 
carriage-return control character (ASCII 0x0D). In all these cases 
(except where I mentioned \n), using the ctrl-V method to enter a 
literal ctrl-M is valid but not practical.

>
> Rob
> :)

Best regards,
Tony.
-- 
"According to the Rand McNally Places-Rated Almanac, the best place to
live in America is the city of Pittsburgh.  The city of New York came
in twenty-fifth.  Here in New York we really don't care too much.
Because we know that we could beat up their city anytime."
                -- David Letterman

--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

Reply via email to