By default to move up (ctrl-p) and to move down (ctrl-n) key bindings are used.

When I am using auto-complete mode, a box with suggested words is pop up. On there when I press ctrl-p or ctrl-n instead of moving within the box, it closes from it. I can move around only by using tab or alt-p or alt-n.

enter image description here

[Q] Inside the box for suggessted word to auto-complete, is there any way to move around by ctrl-p and ctrl-n?

  • Not an answer, but a suggestion: If you're new to emacs and don't have any strong feelings either way, I would strongly suggest you move to use company-mode. It has IMO much better traction. I used to use ac-complete btw. – RichieHH Feb 20 at 23:47
  • Did you try the vertical arrow keys, <up> and <down>? Often those are used (also or instead) in places where you might expect C-p and C-n, respectively, to be used . – Drew Feb 21 at 0:05
  • vertical arrow keys work, but actually I get used to use ctrl-p and ctrl-n all the time @Drew – alper Feb 21 at 6:45
  • Then bind C-p and C-n to the commands you want in the relevant keymap (maybe it's auto-complete-mode-map?). – Drew Feb 21 at 16:50

You can configure that behaviour via customize.

Just do M-x customize-option <return> ac-use-menu-map <return>, then set this option to on (non-nil) and save it for future use.

Thats it.

How did I get this information? I looked at the source code. But it was also possible to find this from M-x customize-group <return> auto-complete <return>.

Nevertheless, I would recommend, switching to another completion framework (like company) because auto-complete seems abandoned. With last commit in Jan 2017.

Edit: To enable this behaviour with company, simply bind the keys and corresponding functions in companys keymap:

(with-eval-after-load "company"
  (define-key company-active-map (kbd "C-p") #'company-select-previous-or-abort)
  (define-key company-active-map (kbd "C-n") #'company-select-next-or-abort))
| improve this answer | |
  • I can switch to company but same issue exist on it as well. Is there any way to handle it on company too? – alper Feb 22 at 19:30
  • @alper yes, I edited my answer – jue Feb 22 at 20:57
  • Thanks! It is possible to activate C-h for delete character as well on company? instead of deleting it says No documentation available. – alper Feb 23 at 10:37

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.