Thursday, September 13, 2018

Problems using v:errmsg

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", don@cs.byu.edu

.--. 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 vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment