Monday, January 18, 2016

How to handle entering and leaving of cmd-line?

Hello Vim-users,

I want hook the entering end leaving of the cmd-line mode and fetch new error messages by reading v:errmsg.
How can I handle both events?

Until now I tried the following: The entering cmd-line mode is catched by
nnoremap <expr> : StartCommandLine(':')
whereas the function returns ':'. I think this work as aspected, but it will called in many VimScript functions, too, didn't it?

The leaving event seems more tricky. I've tried two approches.
1. Remap <CR>
cmap <silent> <CR> <CR><Plug><C-7>
map <expr> <Plug><C-7> EndCommandLine()
(map should cover cmap and nmap.)

Unfortunately EndCommandLine() will not be invoked if the cmd-line produce an error.
':echo "ok"<CR>' works, but ':echo undefined_var<CR>' not.


2. Use an automd. event. I've found ShellCmdPost as predefined event.
(i.e. 'autocmd ShellCmdPost * call EndCommandLine()' )
But this event will only be fired for a small subset of commands and the list is defined
directly in the executable.

Does anybody has an idea how to fetch the event "user closes the cmd-line" (with a small footprint ;))?


Regards,
Olaf

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