vim-maktaba icon indicating copy to clipboard operation
vim-maktaba copied to clipboard

Implement #mapping#MapUntilTimeout

Open dbarnett opened this issue 5 years ago • 0 comments

Maktaba should define a maktaba#mapping#MapUntilTimeout helper to be able to create short-lived mappings that only last until the 'timeout' period expires, so they'll handle certain keypresses only if they happen immediately after something else.

This allows you to define "ambiguous" mappings and prefixes intelligently so a mapping can take immediate action but "change its mind" and take further action if you keep pressing keys.

For example, I've defined this mapping in my vimrc to unfold one level if you press z> or all levels if you press z>>, but with the z> taking effect immediately after pressing it:

nnoremap z> zr:call maktaba#mapping#MapUntilTimeout('nnore', '>', 'zR')<CR>

dbarnett avatar Mar 21 '20 22:03 dbarnett