@@ -291,15 +291,21 @@ The value of the dict keys can be a |Funcref|. For example, a lambda:
291291 \ ]
292292<
293293This would match a 10-digit number and pass it along to the external `date`
294- command, replacing it with the result. The lambda takes one argument, which a
295- list of the full match, and each individual subgroup. So, `m [0 ]` would be the
296- entire match, while `m [2 ]` would be the second group, the equivalent of `\2 `
297- in a | subsitute() | call.
294+ command, replacing it with the result. The lambda (in this case) takes one
295+ argument, which a list of the full match, and each individual subgroup. So,
296+ `m [0 ]` would be the entire match, while `m [2 ]` would be the second group, the
297+ equivalent of `\2 ` in a | subsitute() | call.
298+
299+ The lambda can take up to three arguments:
300+
301+ - The match, as described
302+ - A flag, either 0 or 1 for whether a "reverse" switch was triggered
303+ - A count, so if you'd like, you can pick your replacement from a list
298304
299305Instead of a lambda, it could also be a named function, giving you more space
300306to add more complicated logic:
301307>
302- function! SwitchTimestamp(match)
308+ function! SwitchTimestamp(match, reverse, count )
303309 let result = trim(system('...', a:match[0]))
304310
305311 if v:shell_error
@@ -317,6 +323,12 @@ to add more complicated logic:
317323 \ }
318324 \ ]
319325<
326+ Note that in the explicit function case, you need to handle the full list of
327+ three arguments that the function receives, where in a lambda you could skip
328+ the ones you don't need. You could, alternatively, define the function with
329+ variable arguments and take what you need with | a:1 | , | a:000 | , etc, see
330+ | function-argument | for more details.
331+
320332
321333Nested dict definitions ~
322334
0 commit comments