Skip to main content
Expand short versions of commands
Source Link
D. Ben Knoble
  • 27.7k
  • 3
  • 31
  • 68

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:

funfunction! SetOpFunc()
    set opfunc=CountSpaces
    return 'g@'
endfun
nnonnoremap <expr> <F4> SetOpFunc()

This technique isn't limited to operator mappings either. For example I've used it in Operator-pending mappings to call a function during the mapping without disrupting modes or counts, returning '' at the end. This way you can leverage Vim's native features rather than having to recreate them yourself.

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()

This technique isn't limited to operator mappings either. For example I've used it in Operator-pending mappings to call a function during the mapping without disrupting modes or counts, returning '' at the end. This way you can leverage Vim's native features rather than having to recreate them yourself.

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:

function! SetOpFunc()
    set opfunc=CountSpaces
    return 'g@'
endfun
nnoremap <expr> <F4> SetOpFunc()

This technique isn't limited to operator mappings either. For example I've used it in Operator-pending mappings to call a function during the mapping without disrupting modes or counts, returning '' at the end. This way you can leverage Vim's native features rather than having to recreate them yourself.

additional info.
Source Link
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()

This technique isn't limited to operator mappings either. For example I've used it in Operator-pending mappings to call a function during the mapping without disrupting modes or counts, returning '' at the end. This way you can leverage Vim's native features rather than having to recreate them yourself.

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()

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()

This technique isn't limited to operator mappings either. For example I've used it in Operator-pending mappings to call a function during the mapping without disrupting modes or counts, returning '' at the end. This way you can leverage Vim's native features rather than having to recreate them yourself.

wording
Source Link
Antony
  • 2.6k
  • 12
  • 19

You can call a function transparently within a mapping, thus ignoringcircumventing 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()

You can call a function transparently within a mapping, thus ignoring 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()

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()
superfluous <silent>
Source Link
Antony
  • 2.6k
  • 12
  • 19
Loading
Source Link
Antony
  • 2.6k
  • 12
  • 19
Loading