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?


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)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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