Emacs: isearch by Arrow Keys

By Xah Lee. Date: . Last updated: .

Here's very convenient keys for isearch. Put it in your emacs init.

(progn
  ;; set arrow keys in isearch. left/right is backward/forward, up/down is history. press Return to exit
  (define-key isearch-mode-map (kbd "<up>") 'isearch-ring-retreat )
  (define-key isearch-mode-map (kbd "<down>") 'isearch-ring-advance )

  (define-key isearch-mode-map (kbd "<left>") 'isearch-repeat-backward)
  (define-key isearch-mode-map (kbd "<right>") 'isearch-repeat-forward)

  (define-key minibuffer-local-isearch-map (kbd "<left>") 'isearch-reverse-exit-minibuffer)
  (define-key minibuffer-local-isearch-map (kbd "<right>") 'isearch-forward-exit-minibuffer))

when in isearch, the arrow keys will:

This way, searching forward/backward is just one single key press, no key combination.

This is especially useful with a command that searches current word. See: Emacs: isearch Current Word.

For basics of isearch, see: Emacs: Search / Highlight Word.

Like my tutorial? Put $5 at patreon

Or Buy Xah Emacs Tutorial

Or buy a nice keyboard: Best Keyboard for Emacs

Ask me question on patreon