emacsspaceminibuffer

How to set SPC to act as Enter in minibuffer mode?


When I edit in minibuffer mode, I must press Enter to exit minibuffer.

But I prefer to use Space.

  1. "Space" completes word again and again.

  2. When the message is "Sole Completion", press Space to exit minibuffer.

Defaullt Space key in the second step cannot exit minibuffer, I remap it , but it not works at all.

(define-key minibuffer-local-map (kbd "SPC") `minibuffer-complete-and-exit)

any idea?


Solution

  • Need to define a key in the minibuffer-local-completion-map:

    (define-key minibuffer-local-completion-map (kbd "SPC") 'minibuffer-complete-and-exit)