-*autocmd.txt* For Vim version 9.1. Last change: 2025 Jun 19
+*autocmd.txt* For Vim version 9.1. Last change: 2025 Aug 23
VIM REFERENCE MANUAL by Bram Moolenaar
<afile> is set to a single character,
indicating the type of command-line.
|cmdwin-char|
+ Sets the |v:char| to the key that exited the
+ command-line (e.g. <CR>, <CTRL-C>, <Esc>).
*CmdlineLeavePre*
CmdlineLeavePre Just before leaving the command line, and
before |CmdlineLeave|. Useful for capturing
or <Esc>. <afile> is set to a single
character indicating the command-line type.
See |cmdwin-char| for details.
+ Sets |v:char| as with |CmdlineLeave|.
*CmdwinEnter*
CmdwinEnter After entering the command-line window.
Useful for setting options specifically for
*v:char* *char-variable*
v:char Argument for evaluating 'formatexpr' and used for the typed
character when using <expr> in an abbreviation |:map-<expr>|.
- It is also used by the |InsertCharPre|, |InsertEnter| and
- |KeyInputPre| events.
+ It is also used by the |InsertCharPre|, |InsertEnter|,
+ |KeyInputPre|, |CmdlineLeave| and |CmdlineLeavePre| events.
*v:charconvert_from* *charconvert_from-variable*
v:charconvert_from
ANGLE BRACKET "]>".
- Support for Unix domain sockets have been added for the clientserver
feature, see |socketserver-clientserver|.
+- |CmdlineLeave| sets |v:char| to the character that caused exiting the
+ Command-line.
Platform specific ~
- MS-Winodws: Paths like "\Windows" and "/Windows" are now considered to be
#endif
|| c == Ctrl_C))
{
+#ifdef FEAT_EVAL
+ set_vim_var_char(c); // Set v:char
+#endif
trigger_cmd_autocmd(cmdline_type, EVENT_CMDLINELEAVEPRE);
event_cmdlineleavepre_triggered = TRUE;
#if defined(FEAT_SEARCH_EXTRA) || defined(PROTO)
returncmd:
// Trigger CmdlineLeavePre autocommands if not already triggered.
if (!event_cmdlineleavepre_triggered)
+ {
+#ifdef FEAT_EVAL
+ set_vim_var_char(c); // Set v:char
+#endif
trigger_cmd_autocmd(cmdline_type, EVENT_CMDLINELEAVEPRE);
+ }
#ifdef FEAT_RIGHTLEFT
cmdmsg_rl = FALSE;
need_wait_return = FALSE;
// Trigger CmdlineLeave autocommands.
+#ifdef FEAT_EVAL
+ set_vim_var_char(c); // Set v:char
+#endif
trigger_cmd_autocmd(cmdline_type, EVENT_CMDLINELEAVE);
State = save_State;
void wildmenu_cleanup(cmdline_info_T *cclp);
void f_getcompletion(typval_T *argvars, typval_T *rettv);
void f_getcompletiontype(typval_T *argvars, typval_T *rettv);
-void f_cmdcomplete_info(typval_T *argvars, typval_T *rettv);
+void f_cmdcomplete_info(typval_T *argvars UNUSED, typval_T *rettv);
/* vim: set ft=c : */
call StopVimInTerminal(buf)
endfunc
+func Test_CmdlineLeave_vchar_keys()
+ func OnLeave()
+ let g:leave_key = v:char
+ endfunction
+
+ new
+ for event in ["CmdlineLeavePre", "CmdlineLeave"]
+ exec "autocmd" event "* :call OnLeave()"
+ for key in ["\<C-C>", "\<Esc>", "\<CR>"]
+ call feedkeys($":echo{key}", 'tx')
+ call assert_equal(key, g:leave_key)
+ endfor
+ exec "autocmd!" event
+ endfor
+ bwipe!
+ delfunc OnLeave
+ unlet g:leave_key
+endfunc
+
" vim: shiftwidth=2 sts=2 expandtab
static int included_patches[] =
{ /* Add new patch number below this line */
+/**/
+ 1679,
/**/
1678,
/**/