>>I've got a file with some control characters and I want to replace 
>>one of them with a new line.  I've tried:
>>:s/\%x03/\n/
>>:s/\%x03/^M^J/
>>:s/\%x03/\%x0a/
>
>In the search-for field, you can use '\n' to search for a newline and
>span more than one line.
>
>In the replace-with field, you need to use '\r' instead.  Something
>about the way 'vi' variants store lines internally, that each string is
>null-terminated and there doesn't exist an explicit newline char, so you
>need to insert a return char (the '\r') in the replace-with field to
>tell it to split the line.
>
>Soooo
>
>       :s/^V^C/\r/             <-- ctl-V ctl-C is shorter,
>                                   else the "\%x03" will work fine
>
>should do what you want.
>
>Same with ^B that you aked about earlier, no?

Gene:

Thanks very much.  Yes that is what I needed.  And the text I'm 
playing with came from some serial data and has STX ETX wrapping the 
real data.  I was getting rid of the STX and trying to convert the 
ETX to end of line.

And since I'm on a windows machine, Yakov suggested ^Q instead of ^V. 
 So I think I've got it, till the next time any way.

Thanks,

-- 
Knute Johnson
Molon Labe...


Reply via email to