> Is it possible to check the return code of an Ex command? I currently
> have:
>
> function! Grep(pattern, location)
> exe "noautocmd vimgrep /" . a:pattern . "/gj " . a:location " | copen"
> endfunction
>
> which causes an error with copen if vimgrep doesn't return anything.
> I'd like to handle the error a little more gracefully if possible.
You can use a :try :catch block and catch pattern E480.
(Seems like the help tag E480 is wrong).
And you can also check, whether the result returned by getqflist() is
empty.
see
:h :try
:h :catch
:h getqflist()
regards,
Christian
--
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
To unsubscribe, reply using "remove me" as the subject.
No comments:
Post a Comment