9.4.2 Completion Commands

Here is a list of the completion commands defined in the minibuffer when completion is allowed.

TAB

Complete the text in the minibuffer as much as possible; if unable to complete, display a list of possible completions (minibuffer-complete).

SPC

Complete up to one word from the minibuffer text before point (minibuffer-complete-word). This command is not available for arguments that often include spaces, such as file names.

RET

Submit the text in the minibuffer as the argument, possibly completing first (minibuffer-complete-and-exit). See Completion Exit.

?

Display a list of completions (minibuffer-completion-help).

TAB (minibuffer-complete) is the most fundamental completion command. It searches for all possible completions that match the existing minibuffer text, and attempts to complete as much as it can. See How Completion Alternatives Are Chosen, for how completion alternatives are chosen.

SPC (minibuffer-complete-word) completes like TAB, but only up to the next hyphen or space. If you have ‘auto-f’ in the minibuffer and type SPC, it finds that the completion is ‘auto-fill-mode’, but it only inserts ‘ill-’, giving ‘auto-fill-’. Another SPC at this point completes all the way to ‘auto-fill-mode’.

If TAB or SPC is unable to complete, it displays a list of matching completion alternatives (if there are any) in another window. You can display the same list with ? (minibuffer-completion-help). The following commands can be used with the completion list:

M-DOWN
M-UP

While in the minibuffer, M-DOWN (minibuffer-next-completion and M-UP (minibuffer-previous-completion) navigate through the completions and displayed in the completions buffer. When minibuffer-completion-auto-choose is non-nil (which is the default), using these commands also inserts the current completion candidate into the minibuffer. If minibuffer-completion-auto-choose is nil, you can use the M-RET command (minibuffer-choose-completion) to insert the completion candidates into the minibuffer. By default, that exits the minibuffer, but with a prefix argument, C-u M-RET inserts the currently active candidate without exiting the minibuffer.

M-v
PageUp
prior

Typing M-v, while in the minibuffer, selects the window showing the completion list (switch-to-completions). This paves the way for using the commands below. PageUp, prior and M-g M-c do the same. You can also select the window in other ways (see Multiple Windows).

RET
mouse-1
mouse-2

While in the completion list buffer, this chooses the completion at point (choose-completion). With a prefix argument, C-u RET inserts the completion at point into the minibuffer, but doesn’t exit the minibuffer—thus, you can change your mind and choose another candidate.

TAB
RIGHT
n

While in the completion list buffer, these keys move point to the following completion alternative (next-completion).

S-TAB
LEFT
p

While in the completion list buffer, these keys move point to the previous completion alternative (previous-completion).

q

While in the completion list buffer, this quits the window showing it and selects the window showing the minibuffer (quit-window).

z

While in the completion list buffer, kill it and delete the window showing it (kill-current-buffer).