noctuid / evil-guide

Draft of a guide for using emacs with evil
GNU General Public License v3.0
1.25k stars 59 forks source link

How to make ESC key send isearch-abort instead of isearch-cancel while searching? #279

Closed JohnWick95 closed 2 years ago

JohnWick95 commented 2 years ago

Hello,

A problem while searching in EVIL using / (with isearch) and pressing ESC is that the point doesn't go back to where the search started but pressing Ctrl-g instead of ESC does send you back. It looks like ESC is mapped to isearch-cancel and Ctrl-g is mapped to isearch-abort.

I have tried with many variations from your guide explanations to map ESC to isearch-abort instead of isearch-cancel with no success.

How can I make ESC send isearch-abort during a search? I know about the evil-search module which does the 'correct' thing but lacks the features of isearch which I prefer.

noctuid commented 2 years ago

I don't use isearch, but you should just be able to bind it in isearch-mode-map:

(define-key isearch-mode-map (kbd "<escape>") #'isearch-abort)
JohnWick95 commented 2 years ago

Great, I was playing with variations of something like:

(evil-define-key 'normal isearch-mode-map (kbd "<escape>") #'isearch-abort)

Thank you