When company-mode pops up suggestions, I want to use C-n and C-p to select the next or the previous options, instead of M-n and M-p.

Having found the general answer on this site, I was happy to try it out, but it turns out that doesn't work for me. I suspect this is because I have Evil mode enabled.

When I'm in evil-insert-mode, pressing C-h k C-n tells me:

C-n runs the command evil-next-line (found in evil-insert-state-map),
which is an interactive compiled Lisp function in ‘evil-commands.el’.

It is bound to C-n.

(evil-next-line &optional COUNT)

Move the cursor COUNT lines down.

Is there any way I can shadow this correctly in company-active-map?

For completeness, my configuration is:

(with-eval-after-load 'company
  (define-key company-active-map (kbd "M-n") nil)
  (define-key company-active-map (kbd "M-p") nil)
  (define-key company-active-map (kbd "C-n") #'company-select-next)
  (define-key company-active-map (kbd "C-p") #'company-select-previous))
  • Try this one, works with my setup: (with-eval-after-load 'company (with-eval-after-load 'evil (evil-define-key nil company-active-map (kbd "C-s") #'company-select-next)))
    – Hubisan
    Aug 16, 2019 at 13:07
  • hmm, yours actually works as well :-) Are you using evil-collection? Maybe the after 'evil is needed as this might overwrite it globally. Or as it tells you about insert state map: (evil-define-key 'insert company-active-map (kbd "C-n") #'company-select-next)
    – Hubisan
    Aug 16, 2019 at 13:12

1 Answer 1


I wish I understood why, but thanks to @Hubisan's comment I was able to get it to work. I have tried many permutations, but this is the only one that seems to actually work:

(with-eval-after-load 'evil
  (with-eval-after-load 'company
    (define-key evil-insert-state-map (kbd "C-n") nil)
    (define-key evil-insert-state-map (kbd "C-p") nil)
    (evil-define-key nil company-active-map (kbd "C-n") #'company-select-next)
    (evil-define-key nil company-active-map (kbd "C-p") #'company-select-previous)))

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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