Nikolay Pavlov wrote:
> One of the points of initial suggestion was that `submatch()` is too
> long to type, `{m, c1, c2 -> c2 . c1 }` (pattern looks like `\(c1\)
> \(c2\)`, `m='c1 c2'`) is easier. Using lambdas like this just avoids
> escaping, though it alone already is a good improvement over current
> \= syntax.
Yeah, I was wondering if we can pass the list of submatches to the
function.
substitute(text, '\<\k*\>', {m -> 'key-' . m[0]}, 'g')
Currently it would be:
substitute(text, '\<\k*\>', {-> 'key-' . submatch(0)}, 'g'
It does require that the function takes one argument, even when not
using it:
substitute(text, '\<\k*\>', {m -> 'key-' . g:key}, 'g')
--
WOMAN: King of the who?
ARTHUR: The Britons.
WOMAN: Who are the Britons?
ARTHUR: Well, we all are. we're all Britons and I am your king.
The Quest for the Holy Grail (Monty Python)
/// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\ an exciting new programming language -- http://www.Zimbu.org ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
--
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
---
You received this message because you are subscribed to the Google Groups
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.