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

114869Re: Unable to catch specific error [was: Re: delete lines from while loop]

Expand Messages
  • Andrei Popescu
    Jun 2, 2010
    • 0 Attachment
      [sorry for replying to myself]

      On Mi, 02 iun 10, 11:32:03, Andrei Popescu wrote:
      >
      > fu! <SID>RemoveFuzzy() range
      > execute ':''<,''>global/^#,\sfuzzy$\|^#|\s.*".*"$/d'
      > for linenum in range(a:firstline, a:lastline)
      > let line = getline(linenum)
      > if line =~ '^#,\(.*,\)\=\s*fuzzy'
      > call setline(linenum, substitute(line, ',\s*fuzzy', '', ""))
      > endif
      > endfor
      > endf
      >
      > I tried (no pun intended) to replace the 'for' loop with:
      >
      > try
      > execute ':''<,''>global/^#,\(.*,\)\=\s*fuzzy/s/,\s*fuzzy//'
      > catch /^Vim\%((\a\+)\)\=:E486/ " based on example from :help catch
      > endtry
      >
      > but I still get:
      >
      > E486: Pattern not found: ^#,\(.*,\)\=\s*fuzzy

      Much simpler:

      execute ':''<,''>s/,\s*fuzzy//e'

      but I'm still curious why the :catch doesn't work...

      Regards,
      Andrei
      --
      http://nuvreauspam.ro/2010/05/4-neticheta-pe-mail/
    • Show all 6 messages in this topic