I'd like to make a plugin to display currently pending keys while in operator-pending mode. As the first part of that, how would I register an autocmd to run when operator-pending mode is entered? I'm using neovim, so I'm totally cool if it only works there.
2 Answers
Well, you could always poll Vim:
let s:m = ''
function! MyHandler(timer)
let m = mode(1)
if m != s:m
if m == 'no'
echo "operator pending"
else
echo "-"
endif
let s:m = m
endif
endfunction
Start with:
:call timer_start(250, 'MyHandler', {'repeat': -1})
Not sure if still useful. But for future Google searches...
See h: ModeChanged
-
1Definitely useful, but some some details (say, an example), would make it even better!– husBCommented Jan 8, 2023 at 15:22
:set showcmd
displays? What do you intend to show in addition to that?:h autocmd-events
gives you all of the available autocommand events, and I don't think there is one for entering operator pending mode. But maybe you could do something with some operator pending mode mappings::h omap-info
au ModeChanged *:no* {cmd}