8.3 Editing in the Minibuffer
The minibuffer is an Emacs buffer, albeit a peculiar one, and the usual Emacs commands are available for editing the argument text. (The prompt, however, is read-only, and cannot be changed.)
Since RET
in the minibuffer submits the argument, you can’t use it to insert a newline. You can do that with C-q C-j
, which inserts a C-j
control character, which is formally equivalent to a newline character (see Inserting Text). Alternatively, you can use the C-o
(open-line
) command (see Blank Lines).
Inside a minibuffer, the keys TAB
, SPC
, and ?
are often bound to completion commands, which allow you to easily fill in the desired text without typing all of it. See Completion. As with RET
, you can use C-q
to insert a TAB
, SPC
, or ‘?
’ character.
For convenience, C-a
(move-beginning-of-line
) in a minibuffer moves point to the beginning of the argument text, not the beginning of the prompt. For example, this allows you to erase the entire argument with C-a C-k
.
When the minibuffer is active, the echo area is treated much like an ordinary Emacs window. For instance, you can switch to another window (with C-x o
), edit text there, then return to the minibuffer window to finish the argument. You can even kill text in another window, return to the minibuffer window, and yank the text into the argument. There are some restrictions on the minibuffer window, however: for instance, you cannot split it. See Windows.
Normally, the minibuffer window occupies a single screen line. However, if you add two or more lines’ worth of text into the minibuffer, it expands automatically to accommodate the text. The variable resize-mini-windows
controls the resizing of the minibuffer. The default value is grow-only
, which means the behavior we have just described. If the value is t
, the minibuffer window will also shrink automatically if you remove some lines of text from the minibuffer, down to a minimum of one screen line. If the value is nil
, the minibuffer window never changes size automatically, but you can use the usual window-resizing commands on it (see Windows).
The variable max-mini-window-height
controls the maximum height for resizing the minibuffer window. A floating-point number specifies a fraction of the frame’s height; an integer specifies the maximum number of lines; nil
means do not resize the minibuffer window automatically. The default value is 0.25.
The C-M-v
command in the minibuffer scrolls the help text from commands that display help text of any sort in another window. You can also scroll the help text with M-PageUp
and M-PageDown
(or, equivalently, M-prior
and M-next
). This is especially useful with long lists of possible completions. See Other Window.
Emacs normally disallows most commands that use the minibuffer while the minibuffer is active. To allow such commands in the minibuffer, set the variable enable-recursive-minibuffers
to t
. You might need also to enable minibuffer-depth-indicate-mode
to show the current recursion depth in the minibuffer prompt on recursive use of the minibuffer.
When not active, the minibuffer is in minibuffer-inactive-mode
, and clicking mouse-1
there shows the *Messages*
buffer. If you use a dedicated frame for minibuffers, Emacs also recognizes certain keys there, for example, n
to make a new frame.