Problems using v:errmsg

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Problems using v:errmsg

David Woodfall
I'm trying to detect whether or not a g// command worked by checking
v:errmsg. AFAICT this is almost identical to the example to the
example in :help errmsg, although there it is using 'silent! next':

let v:errmsg = ""
silent! g/^>/

if v:errmsg == ""
   silent g/^-- $/
   silent g/^>/
   normal 2o
else
   normal o
   startinsert
endif
 
However it doesn't seem to work. Whatever I try, v:errmsg is always
empty so the first part of the if statement will run. I've tried with
and without the '!' and also by using normal instead of silent. Doing
:echomsg v:errmsg or :messages after vim has been invoked will always
be empty too.

Any ideas?

-Dave

--

"Linux was made by foreign terrorists to take money from true US companies
like Microsoft." - Some AOL'er.
"To this end we dedicate ourselves..." -Don
  -- From the sig of "Don", [hidden email]

                                                            .--.  oo
                                                           (____)//
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~'

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

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Problems using v:errmsg

Andy Wokula
Am 13.09.2018 um 17:10 schrieb Dave Woodfall:

> I'm trying to detect whether or not a g// command worked by checking
> v:errmsg. AFAICT this is almost identical to the example to the
> example in :help errmsg, although there it is using 'silent! next':
>
> let v:errmsg = ""
> silent! g/^>/
>
> if v:errmsg == ""
>     silent g/^-- $/
>     silent g/^>/
>     normal 2o
> else
>     normal o
>     startinsert
> endif
>
> However it doesn't seem to work. Whatever I try, v:errmsg is always
> empty so the first part of the if statement will run. I've tried with
> and without the '!' and also by using normal instead of silent. Doing
> :echomsg v:errmsg or :messages after vim has been invoked will always
> be empty too.
>
> Any ideas?
>
> -Dave

You may check v:statusmsg instead, because a :global command without
match does not produce an *error*.

--
Andy

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

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Problems using v:errmsg

David Woodfall
On Tuesday 2 October 2018 17:03,
Vim Use <[hidden email]> put forth the proposition:

> Am 13.09.2018 um 17:10 schrieb Dave Woodfall:
> > I'm trying to detect whether or not a g// command worked by checking
> > v:errmsg. AFAICT this is almost identical to the example to the
> > example in :help errmsg, although there it is using 'silent! next':
> >
> > let v:errmsg = ""
> > silent! g/^>/
> >
> > if v:errmsg == ""
> >     silent g/^-- $/
> >     silent g/^>/
> >     normal 2o
> > else
> >     normal o
> >     startinsert
> > endif
> >
> > However it doesn't seem to work. Whatever I try, v:errmsg is always
> > empty so the first part of the if statement will run. I've tried with
> > and without the '!' and also by using normal instead of silent. Doing
> > :echomsg v:errmsg or :messages after vim has been invoked will always
> > be empty too.
> >
> > Any ideas?
> >
> > -Dave
>
> You may check v:statusmsg instead, because a :global command without
> match does not produce an *error*.
>
> --
> Andy

Ah right. Thanks.

--
Dave

"I do not feel obliged to believe that the same God who has endowed us
with sense, reason, and intellect has intended us to forego their use."
    -- Galileo Galilei

                                                            .--.  oo
                                                           (____)//
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~'

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

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.