Call 'operatorfunc'
g@{motion}
Example
Normal 0 / 2Operator pending 1 / 2Normal 2 / 2Call 'operatorfunc'.
Prepared operatorfunc
- Function
Demo(type): let g:last_type = a:type- operatorfunc
Demo- last_type
not called
Await a motion for the prepared custom operator.
Prepared operatorfunc
- Function
Demo(type): let g:last_type = a:type- operatorfunc
Demo- last_type
not called
Call Demo('char') for the word motion and set the operation marks.
Prepared operatorfunc
- Function
Demo(type): let g:last_type = a:type- operatorfunc
Demo- last_type
char- Marks '[ / ']
line 1 columns 1 / 4 (one and its trailing space)
Before & after
Before
Prepared operatorfunc
- Function
Demo(type): let g:last_type = a:type- operatorfunc
Demo- last_type
not called
After
Prepared operatorfunc
- Function
Demo(type): let g:last_type = a:type- operatorfunc
Demo- last_type
char- Marks '[ / ']
line 1 columns 1 / 4 (one and its trailing space)
ILLUSTRATION. Assume +eval. operatorfunc names the prepared harmless Demo(type) function, which records its argument in g:last_type. Complete the operator with w; buffer text is unchanged.
one two
three fourCursor on line 1, column 1Details & Vim help
Call 'operatorfunc'. Use in Normal mode. Braced names stand for the required argument and are not typed literally. Availability and exact behavior can depend on Vim build features, options, mappings and editor state; the linked help is authoritative.