Emacs: Repeat Last Command
Here are 2 useful commands to repeat last command.
Repeat Last Command
- repeat the last command.
Once you called
repeat, you can call it again by pressing or holding down the last key used for invoking
That means, for any command that does not have a shortcut (or if the shortcut is difficult to press), now you can repeat it by simply holding down a key.
Ctrl+x z z z.
It'll do it 3 times.
This is especially useful to repeat
[see Emacs: Keyboard Macro]
Major mode commands usually have keys such as
that is hard to repeat.
repeat command is super useful.
Repeat Last Complex Command
- Repeat the last command that has prompts.
repeat-complex-command is great for:
- Repeating a command without answering the prompts again.
- Get the actual emacs lisp code. Copy paste it elsewhere, edit and eval.
- Converting emacs Regular Expression from interactive form to lisp string form with all proper backslash escape added. [see Emacs Lisp: Convert Regex to Lisp Regex String]
example of repeat-complex-command
list-matching-linesand type the search text (e.g. cat). [see Emacs: Find Replace in Current File]
repeat-complex-command. You get
(list-matching-lines "cat" nil). Press enter to repeat it, or, copy the code and paste in another buffer. you can edit it, and eval it by
eval-last-sexp[see Emacs: Evaluate Elisp Code]
List Command History
- list all recent commands called involving the Minibuffer.