summaryrefslogtreecommitdiffstats
path: root/runtime/doc/map.txt
diff options
context:
space:
mode:
authorYegappan Lakshmanan <yegappan@yahoo.com>2021-11-18 22:08:57 +0000
committerBram Moolenaar <Bram@vim.org>2021-11-18 22:08:57 +0000
commit777175b0df8c5ec3cd30d19a2e887e661ac209c8 (patch)
tree58806429ad4998391464a42f4f4321779642bd2a /runtime/doc/map.txt
parent851c7a699ae00bdc14a4db874cf722b7b7393b53 (diff)
patch 8.2.3619: cannot use a lambda for 'operatorfunc'v8.2.3619
Problem: Cannot use a lambda for 'operatorfunc'. Solution: Support using a lambda or partial. (Yegappan Lakshmanan, closes #8775)
Diffstat (limited to 'runtime/doc/map.txt')
-rw-r--r--runtime/doc/map.txt14
1 files changed, 14 insertions, 0 deletions
diff --git a/runtime/doc/map.txt b/runtime/doc/map.txt
index 4b5dd63305..4d23f4a5dc 100644
--- a/runtime/doc/map.txt
+++ b/runtime/doc/map.txt
@@ -1009,6 +1009,20 @@ or `unnamedplus`.
The `mode()` function will return the state as it will be after applying the
operator.
+The `mode()` function will return the state as it will be after applying the
+operator.
+
+Here is an example for using a lambda function to create a normal-mode
+operator to add quotes around text in the current line: >
+
+ nnoremap <F4> <Cmd>let &opfunc='{t ->
+ \ getline(".")
+ \ ->split("\\zs")
+ \ ->insert("\"", col("'']"))
+ \ ->insert("\"", col("''[") - 1)
+ \ ->join("")
+ \ ->setline(".")}'<CR>g@
+
==============================================================================
2. Abbreviations *abbreviations* *Abbreviations*