Loading ...
Sorry, an error occurred while loading the content.

Re: Bug? One endless :while case

Expand Messages
  • Yue Wu
    ... Thank you, I forgot .* after zs ;p -- Regards, Yue Wu Key Laboratory of Modern Chinese Medicines Department of Traditional Chinese Medicine China
    Message 1 of 3 , Aug 5, 2010
    • 0 Attachment
      On Fri, Aug 06, 2010 at 07:50:37AM +0200, Christian Brabandt wrote:
      > On Fri, August 6, 2010 5:05 am, Yue Wu wrote:
      > > 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.
      >

      Thank you, I forgot '.*' after '\zs' ;p

      --
      Regards,
      Yue Wu

      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
    Your message has been successfully submitted and would be delivered to recipients shortly.