Skip to content

Feat: Set v:char to last key in CmdlineLeave events - #18063

Closed
girishji wants to merge 4 commits into
vim:masterfrom
girishji:veventr
Closed

girishji wants to merge 4 commits into
vim:masterfrom
girishji:veventr

Conversation

@girishji

@girishji girishji commented Aug 20, 2025 •

Copy link
Copy Markdown
Contributor

v:char stores the key that caused the command-line to exit. Examples: <CR>, <Esc>, <C-C>. Applies to CmdlineLeave and CmdlineLeavePre events.

See #17806 (comment)

`cmdline_leave_key` stores the numeric value of the key that caused the
command-line to exit. Examples: 13 (`<CR>`), 27 (`<Esc>`), 3 (`<C-C>`).
@zeertzjq

Copy link
Copy Markdown
Member

The cmdline_leave_key name is a bit verbose. How about just setting v:char instead?

@girishji girishji changed the title Feat: Add v:event['cmdline_leave_key'] to CmdlineLeave events Feat: Set v:char to key in CmdlineLeave events Aug 20, 2025
@girishji girishji changed the title Feat: Set v:char to key in CmdlineLeave events Feat: Set v:char to last key in CmdlineLeave events Aug 20, 2025
M  src/ex_getln.c
@habamax

habamax commented Aug 20, 2025

Copy link
Copy Markdown
Contributor

it works for for me, however:

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

Probably should be updated here too.

PS, I believe v:event.char would have been more idiomatic.

@habamax

habamax commented Aug 20, 2025

Copy link
Copy Markdown
Contributor

All good, works as expected, thank you!

@chrisbra

Copy link
Copy Markdown
Member

thanks

@chrisbra chrisbra closed this in ba9551d Aug 23, 2025
@girishji

Copy link
Copy Markdown
Contributor Author

Thanks.

@girishji
girishji deleted the veventr branch August 24, 2025 06:18
sahinf pushed a commit to sahinf/vim that referenced this pull request Sep 7, 2025
Problem:  unclear what key causes CmdlineLeave autocommand
Solution: Set |v:char| to the key (Girish Palya).

related: vim#17806
closes: vim#18063

Signed-off-by: Girish Palya <[email protected]>
Signed-off-by: Christian Brabandt <[email protected]>
zeertzjq added a commit to zeertzjq/neovim that referenced this pull request Sep 8, 2025
Problem:  unclear what key causes CmdlineLeave autocommand
Solution: Set |v:char| to the key (Girish Palya).

related: vim/vim#17806
closes: vim/vim#18063

vim/vim@ba9551d

Co-authored-by: Girish Palya <[email protected]>
zeertzjq added a commit to zeertzjq/neovim that referenced this pull request Sep 8, 2025
Problem:  unclear what key causes CmdlineLeave autocommand
Solution: Set |v:char| to the key (Girish Palya).

related: vim/vim#17806
closes: vim/vim#18063

vim/vim@ba9551d

Co-authored-by: Girish Palya <[email protected]>
zeertzjq added a commit to neovim/neovim that referenced this pull request Sep 8, 2025
…35677)

Problem:  unclear what key causes CmdlineLeave autocommand
Solution: Set |v:char| to the key (Girish Palya).

related: vim/vim#17806
closes: vim/vim#18063

vim/vim@ba9551d

Co-authored-by: Girish Palya <[email protected]>
dundargoc pushed a commit to dundargoc/neovim that referenced this pull request Sep 27, 2025
…eovim#35677)

Problem:  unclear what key causes CmdlineLeave autocommand
Solution: Set |v:char| to the key (Girish Palya).

related: vim/vim#17806
closes: vim/vim#18063

vim/vim@ba9551d

Co-authored-by: Girish Palya <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants