summaryrefslogtreecommitdiffstats
path: root/runtime/doc/map.txt
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2022-07-06 13:18:11 +0100
committerBram Moolenaar <Bram@vim.org>2022-07-06 13:18:11 +0100
commit5ed11535e0695163cec71033b98bb97356cf0113 (patch)
tree2b1048a6dec6119e70258354b17ac1ffcdb72db3 /runtime/doc/map.txt
parentcf34434b5e840dda4a21cd9c0bee24e3e43a674d (diff)
Update runtime files
Diffstat (limited to 'runtime/doc/map.txt')
-rw-r--r--runtime/doc/map.txt12
1 files changed, 7 insertions, 5 deletions
diff --git a/runtime/doc/map.txt b/runtime/doc/map.txt
index 5efc5076f8..e4332b8d4a 100644
--- a/runtime/doc/map.txt
+++ b/runtime/doc/map.txt
@@ -374,15 +374,17 @@ command: it is executed as if an (unrestricted) |autocommand| was invoked.
<ScriptCmd> is like <Cmd> but sets the context to the script the mapping was
defined in, for the duration of the command execution. This is especially
useful for |Vim9| script. It also works to access an import, which is useful
-in a plugin using an autoload script: >
+in a plugin using a, possibly autoloaded, script: >
vim9script
import autoload 'implementation.vim' as impl
nnoremap <F4> <ScriptCmd>impl.DoTheWork()<CR>
-
+<
No matter where <F4> is typed, the "impl" import will be found in the script
-context of where the mapping was defined. And since it's an autoload import,
-the "implementation.vim" script will only be loaded once <F4> is typed, not
-when the mapping is defined.
+context of where the mapping was defined. When it's an autoload import, as in
+the example, the "implementation.vim" script will only be loaded once <F4> is
+typed, not when the mapping is defined.
+
+Without <ScriptCmd> using "s:impl" would result in "E121: Undefined variable".
Note:
- Because <Cmd> and <ScriptCmd> avoid mode-changes it does not trigger