7

I'm trying Projectile + ido + flx-ido (just for Projectile, ido-mode disabled otherwise).

But: I don't like using right and left to switch between items. I want to change them into up and down, but have been unsuccessful:

(define-key ido-common-completion-map (kbd "<down>") 'ido-next-match)
(define-key ido-common-completion-map (kbd "<up>") 'ido-prev-match)
(define-key ido-completion-map (kbd "<down>") 'ido-next-match)
(define-key ido-completion-map (kbd "<up>") 'ido-prev-match)

My question, therefore, is: How do I bind keys in ido-mode?

Dan
  • 32,584
  • 6
  • 98
  • 168
kuanyui
  • 1,020
  • 6
  • 16

1 Answers1

7

According to the source code, you need to modify keybindings via ido-setup-hook:

;; Customization
;; -------------
;;
;; Customize the `ido' group to change the `ido' functionality.
;;
;; To modify the keybindings, use the ido-setup-hook.  For example:
;;(add-hook 'ido-setup-hook 'ido-my-keys)
;;
;;(defun ido-my-keys ()
;;  "Add my keybindings for ido."
;;  (define-key ido-completion-map " " 'ido-next-match)
;;  )

So do the following:

(defun bind-ido-keys ()
  "Keybindings for ido mode."
  (define-key ido-completion-map (kbd "<down>") 'ido-next-match) 
  (define-key ido-completion-map (kbd "<up>")   'ido-prev-match))

(add-hook 'ido-setup-hook #'bind-ido-keys)
Dan
  • 32,584
  • 6
  • 98
  • 168