[PLUG] vim regex lazy/minimal-matching?
Daniel Logghe
dzl at frenetic.com
Mon Jan 26 17:45:03 UTC 2004
Matt Alexander wrote:
> On Mon, 26 Jan 2004, Matt Alexander wrote:
>
>
>>In Perl I can use ? to stop after the first match.
>>
>>Does anyone know how to do the same type of lazy/minimal-matching in vim?
>
>
>
> OK... here's a little more info on my problem...
>
> Here's a line of text...
>
> something. something. something else. maybe something else too. yep.
>
> I don't know what the text is before each period, and I don't know how
> many periods will appear, but after the first period that I encounter I
> want to insert a tab after that period. The following does not work:
>
> :%s/\(^.*\.\)/\1\t/
>
> The problem with this is that it would match everything up to the very
> last period and would substitute the tab at the end. Yes, I could use
> Perl, but I encounter this problem all the time and I'd like to be able to
> do it from within vim.
> Thanks,
> ~M
I think what you're after in vim is \{-} so your pattern above would be:
:%s/\(^.{-}\.\)/\1\t/
More information about the PLUG
mailing list