I want to disable evil insert key such as a
, i
, o
in read-only
mode (keep navigation key such as j
and k
), my idea is to disable these keys in local buffer when enabling read-only
mode and enable these keys after disabling read-only
mode.
There are two difficulties for me:
- How to disable evil insert key.
- How to execute code when enable/disable mode.
I notice there is evil-disable-insert-state-bindings
variable. I try to set it to t
in local buffer, but a
, i
keys still work.
I know I can use (add-hook 'read-only-mode-hook (lambda () (message "read-only-mode changed")))
to detect mode change, but I don't know how to distinguish enabling and disabling mode.