From: Philippe Verdy (verdy_p@wanadoo.fr)
Date: Tue May 02 2006 - 22:47:56 CST
From: "Alexej Kryukov" <akrioukov@newmail.ru>
> On Monday 01 May 2006 23:11, Philippe Verdy wrote:
>> No it does not work for me: I can't match spans of text that cover
>> several lines. the \n just matches the final \n at end of line but
>> not anything else after it.
>
> What exactly you are doing to search for a newline character? For me
> :/\n<enter> highlights all ends of lines in the current buffer, while
> :%s/\n//<enter> removes all newline characters at all (or replaces
> them with whatever I want). If this is not that you need, please
> describe the problem more precisely.
I use newlines the same way you use it. (Note: I have not precised exactly how newlines are encoded; Idon't care if they use Unix or Mac or DOS style
I just want to be able to match for example "aaaaa\nbbbbbb" and replace it with anything,i.e. not having to play with the ''vi'' join and merge commands; to match "aaaa" and replace it with "ccccccc\ndddddddd".
The later is possible with a sed script using a loop, but the first case requires (with vi or sed) first substituting allnewlines by some unique character like '¤' (using "tr" for example), provided that I'm sure this '¤' substitution character is not present in the whole text, and then I can usesearch/replace patternsusing this unique character, then I have to translate again this '¤' into newlines (using tr).
Such thing is very common when I need to make search/replace operations in XML files with the usual indentation, because search patterns are contextual and include acontext in the previous or next lines. Nut it happens all times when I work on delimited datafiles (notably those that come from database exports and that will beimported into another system).
These plain text files can be very huge, and having to write a special program to filter them is a constant nightmare, notably when such edits is to be performed only once (and its cost with manual edit is too large, and very boring or errorprone to do manually).
This archive was generated by hypermail 2.1.5 : Tue May 02 2006 - 22:50:40 CST