I think company-mode is a great package.
Though I would like to change some keybinding it has assigned by default.

For example, I would prefer not to use M-n and M-p in order to move in the different complete result list. How can I change that?

1 Answer 1


I read about Change Minor Mode Keys in the fantastic Xah Lee pages.
And I think I came with a solution.

I found two different keymaps in company.el: company-active-map and company-search-map.
So I redefined its default keybinding definitions that best suits my needs:

(define-key company-active-map (kbd "C-n") 'company-select-next)
(define-key company-active-map (kbd "C-p") 'company-select-previous)
(define-key company-search-map (kbd "C-n") 'company-select-next)
(define-key company-search-map (kbd "C-p") 'company-select-previous)
(define-key company-search-map (kbd "C-t") 'company-search-toggle-filtering)

That made it for me.

  • I wrapped this in (with-eval-after-load 'company (define-key ...)) to defer define-key calls until company-mode is loaded; otherwise, the keymaps are not defined.
    – rduplain
    Mar 23, 2019 at 19:29
  • Mmm, I am not having that problem, but I am using use-package: github.com/tomasorti/myconf/blob/master/emacs/company.el#L14
    – nephewtom
    Mar 24, 2019 at 20:10
  • Yes, your use-package call will have loaded company-mode. Another option is to (require 'company) if it's already installed (previous use-package call or installed manually). Otherwise, these keybindings must eval after load.
    – rduplain
    Mar 25, 2019 at 1:46

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.