How to detect input status to set shortcut keys?

I want to access web pages in Web mode like vimium. But when I’m in the input state, the shortcut keys conflict with the input letters. How to avoid this situation? This is my config snippet:

2021-12-30 105800

Hmmmmm. I guess what you want is VI mode so that you need to explicitly switch to input mode to type literal text. To rebind keys in it, use scheme:vi-normal instead of scheme:emacs.

You can switch to full VI bindings in Common Settings, or by adding

(define-configuration buffer
  ((default-modes (append '(vi-normal-mode) %slot-default))))

to your config file.

1 Like

I just want to use the vi binding key in the web mode of browsing the web page, while keeping the Emacs key binding. This is somewhat similar to the evil mode. But when I input, it did not switch to insert mode.

That is an understandable requirement. Our VI mode has all the Emacs bindings automatically included in it, and VI bindings added on top. In comparison to VI mode, Emacs one is not modal and thus it always perceives all the keys as commands, unless they are unbound. Using Emacs mode won’t work for your use-case.

Input mode switching should haplen in input area clicks, but it’s imperfect, You’d need to press i while in vi-normal-mode to switch to vi-insert-mode.


Okay, I see. It can be solved. Thank you for your patience.

Is there a solution for entering vi-normal-mode in prompt-buffer? I would like to maintain the same behavior as using just emacs mode in prompt-buffer.

Yes, I have the same problem as you.

I’m confused a bit: do you want vi-normal-mode or emacs-mode in prompt-buffer?

In any way, it all works by adding either of the modes to default-modes of prompt-buffer:

(define-configuration prompt-buffer
  ;; Emacs keybindings. Use `vi-normal-mode' if you want VI bindings instead.
  ((default-modes `(emacs-mode ,@%slot-default%))))