I'm trying to disable the ZZ
mapping in vim, as I found myself accidentally exiting from vim too much by it when trying to use >>
(I use a spanish keyboard).
My attempt is quite obvious:
nnoremap ZZ <Nop>
While it works for my use case, I found that doing Z<wait 1 second>Z
still triggers the "save and quit" behavior.
As I understand Vim waits timeoutlen
milliseconds and, if that time passes, the map doesn't fire and Vim uses the default ZZ
behavior.
My question is, how can I reliably disable ZZ
even when timeoutlen
passes without changing the timeout config?
While writing the question I began tinkering with an idea, and finally come to this:
nnoremap Z <Nop>
nnoremap ZZ <Nop>
This works always, no matter how you press ZZ
; if you press it and waits, the first map fires and clears the Z
, if you don't wait the second fires.
I hope this is useful to someone else.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.