Skip to main content
3 of 5
wording
Antony
  • 2.6k
  • 12
  • 19

You can call a function transparently within a mapping, thus circumventing mode changes (e.g. by pressing :) or losing counts, by using <expr> mappings, similar to what you suggested. Just use them to call a function like so:

fun! SetOpFunc()
    set opfunc=CountSpaces
    return 'g@'
endfun
nno <expr> <F4> SetOpFunc()
Antony
  • 2.6k
  • 12
  • 19