0

Is it possible to use the control key to exit Evil's insert mode? I'm currently using the following code to do it with TAB, but since control only seems to work as a modifier key, I'm not having any luck with it.

;; Map single control to ESC (with-eval-after-load 'evil-maps (define-key evil-insert-state-map (kbd "TAB") 'evil-force-normal-state))

Any thoughts?

1
  • I'm a little late to this question, but in vim you can do <C-[> to escape insert mode, and that binding exists in evil mode as well. Maybe not quite what you are looking for, but it is a way to leave insert mode with the control key. Dec 17, 2017 at 23:52

1 Answer 1

3

No, you cannot, at least not within Emacs. Emacs only understands modifier keys that actually modify something, so CTRL alone will not be recognized.

Some programs (xcape, for instance) allow you to bind a modifier key to do something when it modifies something, and a different thing when you tap and release it. A common use case is to modify the CTRL key to act as ESC when tapped and released.

2
  • I had already found xcape and was hoping for an Emacs-only solution. But I guess I was expecting it to be impossible. Thanks for the answer!
    – brenns10
    Jan 25, 2017 at 5:13
  • 1
    FWIW, I was able to map Caps Lock in Ubuntu using setxkbmap, see this question. Then Caps Lock appears as VoidSymbol in Emacs, so I could do (define-key evil-insert-state-map (kbd "<VoidSymbol>") 'evil-normal-state) to make Caps Lock work as ESC in evil-mode Jan 25, 2017 at 8:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.