Emacs Init: isearch by Arrow Keys

By Xah Lee. Date: . Last updated: .

Here's convenient keys for isearch.

put this in your Emacs Init File:

  ;; 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: Search Current Word 🚀.

For basics of isearch, see: Emacs: Search Text in Current File.

Emacs Find Replace