2

I've found it's common to set opfunc in this manner:

nnoremap <Leader>r :set opfunc=<SID>my_function<CR>g@

With Vim8 supporting lambda functions, is it possible to now set opfunc to a lambda function? The following cursory try did not work:

:set opfunc={-> "test" }
Roxy
  • 177
  • 3

1 Answers1

5

The operatorfunc is a option. A option can only have the types boolean (on/off), number or string (see :help options). So you can't assign a lambda to an option.

Also the documentation help 'operatorfunc' says

This option specifies a function to be called by the g@ operator.

My interpretation of "specifies" is "names".

I had a look at the code (function op_function in normal.c). It calls a vim script function by name.

So the answer is: No

Ralf
  • 9,197
  • 1
  • 11
  • 30