aboutsummaryrefslogtreecommitdiff
path: root/runtime
diff options
context:
space:
mode:
authorBjörn Linse <bjorn.linse@gmail.com>2016-03-14 23:58:47 +0100
committerBjörn Linse <bjorn.linse@gmail.com>2018-03-23 14:01:49 +0100
commitd407a48665d8f8e1e42eb1060ea245d979419605 (patch)
treee9e69777347e92618603f3d0d8bc54f81486a663 /runtime
parentce3bc12e25f19d29c74e53a8a7f92079b1ccfcbf (diff)
downloadrneovim-d407a48665d8f8e1e42eb1060ea245d979419605.tar.gz
rneovim-d407a48665d8f8e1e42eb1060ea245d979419605.tar.bz2
rneovim-d407a48665d8f8e1e42eb1060ea245d979419605.zip
getchar: implement <Cmd> key to invoke command in any mode
Diffstat (limited to 'runtime')
-rw-r--r--runtime/doc/map.txt27
1 files changed, 26 insertions, 1 deletions
diff --git a/runtime/doc/map.txt b/runtime/doc/map.txt
index 9b61fa6527..038e90fab0 100644
--- a/runtime/doc/map.txt
+++ b/runtime/doc/map.txt
@@ -232,8 +232,10 @@ For this reason the following is blocked:
- Editing another buffer.
- The |:normal| command.
- 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.
+that. Alternatively use a |<Cmd>| mapping which doesn't have these
+restrictions.
You can use getchar(), it consumes typeahead if there is any. E.g., if you
have these mappings: >
@@ -272,6 +274,29 @@ again for using <expr>. This does work: >
Using 0x80 as a single byte before other text does not work, it will be seen
as a special key.
+ *<Cmd>* *:map-command*
+A command mapping is a mapping that directly executes a command. Command
+mappings are written by placing a command in between <Cmd> and <CR> in the
+rhs of a mapping (in any mode): >
+ noremap <f3> <Cmd>echo mode(1)<cr>
+<
+ *E5520*
+The command must be complete and ended with a <CR>. If the command is
+incomplete, an error is raised. |Command-line| mode is never entered.
+
+This is more flexible than using `:<c-u>` in visual and operator pending
+mode, or `<c-o>:` in insert mode, as the commands are exectued directly in the
+mode, and not normal mode. Also visual mode is not aborted. Commands can be
+invoked directly in cmdline mode, which is not simple otherwise (a timer has
+to be used). Unlike <expr> mappings, there are not any specific restrictions
+what the command can do, except for what is normally possible to do in every
+specific mode. The command should be executed the same way as if an
+(unrestricted) |autocmd| was invoked or an async event event was processed.
+
+Note: In select mode, |:map| or |:vmap| command mappings will be executed in
+visual mode. If a mapping is intended to work in select mode, it is
+recomendend to map it using |:smap|, possibly in addition to the same mapping
+with |:map| or |:xmap|.
1.3 MAPPING AND MODES *:map-modes*
*mapmode-nvo* *mapmode-n* *mapmode-v* *mapmode-o* *mapmode-t*