Re: Bug? One endless :while case
- On Fri, Aug 06, 2010 at 07:50:37AM +0200, Christian Brabandt wrote:
> On Fri, August 6, 2010 5:05 am, Yue Wu wrote:Thank you, I forgot '.*' after '\zs' ;p
> > Create a func:
> > func! Ywtest()
> > redraw | let txt = matchstr(input("Foo: "), '^\s*\zs.*')
> > while txt == ''
> > let txt = matchstr(input("Foo: "), '^\s*\zs')
> > endwhile
> > endfunc
> > Run it: :call Ywtest()
> > Then in the first prompt, hit enter to enter a blank string, then func
> > will
> > prompt again, now input some string, hit enter again, you will find the
> > while
> > loop will nerver end from now on.
> > If I remove the matchstr() part, func runs well, what's wrong with it?
> Because your pattern always matches and since you are using \zs at the
> end of your pattern, matchstr() will always return the empty string.
Key Laboratory of Modern Chinese Medicines
Department of Traditional Chinese Medicine
China Pharmaceutical University
No.24, Tongjia Xiang Street, Nanjing 210009, China
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php