Mercurial > vim
diff src/normal.c @ 22862:6d50182e7e24 v8.2.1978
patch 8.2.1978: making a mapping work in all modes is complicated
Commit: https://github.com/vim/vim/commit/957cf67d50516ba98716f59c9e1cb6412ec1535d
Author: Bram Moolenaar <Bram@vim.org>
Date: Thu Nov 12 14:21:06 2020 +0100
patch 8.2.1978: making a mapping work in all modes is complicated
Problem: Making a mapping work in all modes is complicated.
Solution: Add the <Cmd> special key. (Yegappan Lakshmanan, closes https://github.com/vim/vim/issues/7282,
closes 4784, based on patch by Bjorn Linse)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Thu, 12 Nov 2020 14:30:04 +0100 |
parents | f7f2d73ff85e |
children | d10a37eb91ee |
line wrap: on
line diff
--- a/src/normal.c +++ b/src/normal.c @@ -375,6 +375,7 @@ static const struct nv_cmd #endif {K_CURSORHOLD, nv_cursorhold, NV_KEEPREG, 0}, {K_PS, nv_edit, 0, 0}, + {K_COMMAND, nv_colon, 0, 0}, }; // Number of commands in nv_cmds[]. @@ -3312,10 +3313,11 @@ nv_exmode(cmdarg_T *cap) static void nv_colon(cmdarg_T *cap) { - int old_p_im; - int cmd_result; - - if (VIsual_active) + int old_p_im; + int cmd_result; + int is_cmdkey = cap->cmdchar == K_COMMAND; + + if (VIsual_active && !is_cmdkey) nv_operator(cap); else { @@ -3325,7 +3327,7 @@ nv_colon(cmdarg_T *cap) cap->oap->motion_type = MCHAR; cap->oap->inclusive = FALSE; } - else if (cap->count0) + else if (cap->count0 && !is_cmdkey) { // translate "count:" into ":.,.+(count - 1)" stuffcharReadbuff('.'); @@ -3343,7 +3345,7 @@ nv_colon(cmdarg_T *cap) old_p_im = p_im; // get a command line and execute it - cmd_result = do_cmdline(NULL, getexline, NULL, + cmd_result = do_cmdline(NULL, is_cmdkey ? getcmdkeycmd : getexline, NULL, cap->oap->op_type != OP_NOP ? DOCMD_KEEPLINE : 0); // If 'insertmode' changed, enter or exit Insert mode