Wednesday, June 2, 2010

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

[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/

No comments: