RE: Buffer actions
- Yes, that did work! Thanks.
From: Tim Chase [mailto:vim@...]
Sent: den 5 maj 2005 00:00
To: Persson Jonas
Subject: Re: Buffer actions
>> :bufdo let found=0 | exe "0;/regexp/g/regexp/let found=1" |Sorry...some of that was a bit untested, trying to add your handy
>> if (!found) | $put ='hello' | endif
> Unfortunatly this did not work. If the pattern is not found,
> the command is aborted with "E486: Pattern not found" before
> the if() is executed.
"cut" technique (in Prolog terminology) to only set it once. Try
:bufdo let found=0 | exe "g/regexp/let found=1" | if (!found) |
$put ='hello' | endif
which can set "found" more than once...inefficient, but not
killer. This was the actual expression I tested, but wanted to
try your technique of using the "0;/regexp/" which looked
promising. However, I forgot about the error-condition
triggering a stop.