eregex.vim
eregex.vim copied to clipboard
Substitution with an expression breaks messages
Vim: 8.0 OS: Linux (Arch) eregex: 950027d
Messages created with echom(sg) aren't displayed correctly or saved to the message history when using :%S/<pattern>/\=<expression>/.
echom-vimrc
call plug#begin()
Plug 'othree/eregex.vim'
call plug#end()
set nocompatible
" echo the supplied arg and return it unchanged
function! Echo(arg)
echomsg 'arg: ' . a:arg
return a:arg
endfunction
steps to reproduce
native (:substitute)
- open a file with
vim -u echom-vimrc test.txt - insert the word "foo", and replace it with:
:%s/foo/\=Echo('bar')/ - undo the change, then re-run the substitution
- the message ("arg: foo") is displayed after each substitution, and appears twice in the output of
:messages
eregex (:S)
- open a file with
vim -u echom-vimrc test.txt - insert the word "foo", and replace it with:
:%S/foo/\=Echo('bar')/ - undo the change, then re-run the substitution
- the message ("arg: foo") is only displayed after the first substitution, and doesn't appear at all in the output of
:messages
I can reproduce and I got 0 message. Still looking.
It use silent to execute substitute ref: http://vimdoc.sourceforge.net/htmldoc/various.html#:silent
Not sure why original author try to manage error by itsself. https://github.com/othree/eregex.vim/blob/master/plugin/eregex_e.vim#L4-L6 https://github.com/othree/eregex.vim/blob/master/plugin/eregex.vim#L844-L873