diff options
author | zeertzjq <zeertzjq@outlook.com> | 2023-05-08 01:34:38 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-05-08 01:34:38 +0800 |
commit | 13e7e4e67ada0cd359977ca1f56ef9d8ce8c938c (patch) | |
tree | 5d9f239d6421d94f2327df672500332ec72b099f /runtime/doc/map.txt | |
parent | 1cbfed03c249e7f9e67d59566fbabe46f7f7f1f9 (diff) | |
parent | 5844af0d524956b55100e4350934237e4a12a147 (diff) | |
download | rneovim-13e7e4e67ada0cd359977ca1f56ef9d8ce8c938c.tar.gz rneovim-13e7e4e67ada0cd359977ca1f56ef9d8ce8c938c.tar.bz2 rneovim-13e7e4e67ada0cd359977ca1f56ef9d8ce8c938c.zip |
Merge pull request #23527 from zeertzjq/vim-8.2.1978
vim-patch:8.2.{1978,2062,3887},9.0.{1516,1521}
Diffstat (limited to 'runtime/doc/map.txt')
-rw-r--r-- | runtime/doc/map.txt | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/runtime/doc/map.txt b/runtime/doc/map.txt index 164e2d4ec5..9ec592215e 100644 --- a/runtime/doc/map.txt +++ b/runtime/doc/map.txt @@ -290,7 +290,7 @@ Therefore the following is blocked for <expr> mappings: - Moving the cursor is allowed, but it is restored afterwards. - If the cmdline is changed, the old text and cursor position are restored. If you want the mapping to do any of these let the returned characters do -that. (Or use a |<Cmd>| mapping instead.) +that, or use a |<Cmd>| mapping instead. You can use getchar(), it consumes typeahead if there is any. E.g., if you have these mappings: > @@ -324,19 +324,21 @@ be seen as a special key. *<Cmd>* *:map-cmd* The <Cmd> pseudokey begins a "command mapping", which executes the command -directly (without changing modes). Where you might use ":...<CR>" in the +directly without changing modes. Where you might use ":...<CR>" in the {rhs} of a mapping, you can instead use "<Cmd>...<CR>". Example: > - noremap x <Cmd>echo mode(1)<cr> + noremap x <Cmd>echo mode(1)<CR> < -This is more flexible than `:<C-U>` in visual and operator-pending mode, or -`<C-O>:` in insert-mode, because the commands are executed directly in the -current mode (instead of always going to normal-mode). Visual-mode is +This is more flexible than `:<C-U>` in Visual and Operator-pending mode, or +`<C-O>:` in Insert mode, because the commands are executed directly in the +current mode, instead of always going to Normal mode. Visual mode is preserved, so tricks with |gv| are not needed. Commands can be invoked -directly in cmdline-mode (which would otherwise require timer hacks). +directly in Command-line mode (which would otherwise require timer hacks). +Example of using <Cmd> halfway Insert mode: > + nnoremap <F3> aText <Cmd>echo mode(1)<CR> Added<Esc> Unlike <expr> mappings, there are no special restrictions on the <Cmd> -command: it is executed as if an (unrestricted) |autocommand| was invoked +command: it is executed as if an (unrestricted) |autocmd| was invoked or an async event event was processed. Note: @@ -350,7 +352,7 @@ Note: - In Visual mode you can use `line('v')` and `col('v')` to get one end of the Visual area, the cursor is at the other end. - *E5520* + *E1255* *E1136* <Cmd> commands must terminate, that is, they must be followed by <CR> in the {rhs} of the mapping definition. |Command-line| mode is never entered. |