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?
Emacs Stack Exchange is a question and answer site for those using, extending or developing Emacs. It only takes a minute to sign up.
Sign up to join this communityI 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.
(with-eval-after-load 'company (define-key ...))
to defer define-key
calls until company-mode is loaded; otherwise, the keymaps are not defined.
use-package
: github.com/tomasorti/myconf/blob/master/emacs/company.el#L14
Mar 24, 2019 at 20:10
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.