A.J.Mechelynck wrote:
Nikolaos A. Patsopoulos wrote:
Yakov Lerner wrote:
On 9/13/06, Nikolaos A. Patsopoulos <[EMAIL PROTECTED]> wrote:
Yakov Lerner wrote:
> On 9/13/06, Nikolaos A. Patsopoulos <[EMAIL PROTECTED]> wrote:
>> Yakov Lerner wrote:
>> > On 9/13/06, Nikolaos A. Patsopoulos <[EMAIL PROTECTED]> wrote:
>> >> Hi,
>> >>
>> >> I'm trying to delete several lines from the beginning of file till
>> the
>> >> appearance of a specific pattern, without deleting the pattern. I
>> have
>> >> used the following command:
>> >>
>> >> :1,/Citations: /d/e-10
>> >>
>> >> but the offset doesn't work.
>> >
>> > Try this:
>> >
>> >          :1,/Citations: /-1d
>> >
>> > Caution: This works except in the case when pattern is found in the
>> > 1st line.
>> >
>> > Yakov
>> >
>> >
>> That's work fine, thanks!
>>
>> Can I ask another question? How can someone substitute or delete a block
>> of text which expands to more than one line? E.g. the text:
>>
>> Morning bgfn nbgfn............................more text..
>> ........more text...............
>> ....................... end of text.
>>
>> Can I use a sth like this?
>>
>> s/Morning,text/anothertext
>
> try
>   :s/Morning\_.*text/anothertext/
> or
>   :s/Morning\(\n\|.\)*text/anothertext/
>
> :help \_
> Yakov
>
>
Sorry, that works but I forgot to mention that I have many occurrences
of  /text/ (last word in block) and I want to substitute  to the first
occurrence only.

Then you change * in the pattern for \{-}

Yakov


this seems like a never-ending question:

what if I have more than of the same blocks? How can I use the sub command to replace all occurrences of the same block in a file?



To replace pattern1 by text2 everywhere in the file (including several times on a line):

    :1,$s/pattern1/text2/g

1,$ is a "range" of lines (in this case: line 1 to last line)

see
    :help :s
    :help [range]


Best regards,
Tony.


I used
:%s/\(<a href\_.\{-}\Source:\)/<b>Source:/g (<a_href is the beginning of the block and Source is the end)

but all the occurrences of the block are mixed up, since the code is been repeated till the block is not found, while it should stop at the first pass of the whole file.

Reply via email to