Emacs: Universal Argument (C-u prefix arg)
What is Universal Argument
universal-argument 【Ctrl+u】
allows you to give argument to commands, interactively.
What the command do with argument depends on the command. It may repeat the command, or have different behavior (e.g. copy file name without dir path, or copy full path.) .
Example of universal-argument
- Type Ctrl+u 60 - to insert hyphen, 60 times.
- In dired,
dired-copy-filename-as-kill【w】 copies the file name, but type Ctrl+u 0 first, then w, the copied name is file full path.
- with Ctrl+u,
shellstarts a new buffer
- with Ctrl+u,
shell-command-on-regionreplace region with output.
digit-argument, negative-argument
These are equivalent of universal-argument.
digit-argumentis equivalent to callinguniversal-argument【Ctrl+u】 then type a number.negative-argumentis equivalent to callinguniversal-argument【Ctrl+u】 then type a negative number.
Keyboard shortcuts for digit-argument
- The keys Ctrl+1 to Ctrl+9 and Meta+1 to Meta+9 are bound to
digit-argument. - The key Ctrl+- and Meta+- calls
negative-argument.
Emacs Principle
- Emacs: Principle, Command, Keys
- Emacs: Jargons (Glossary)
- Emacs: Mode Line (Status Bar)
- Emacs: Major Mode
- Emacs: Minor Mode
- Emacs Init: Hook
- Emacs: Minibuffer
- Emacs: Messages Buffer
- Emacs: Universal Argument (C-u prefix arg)
- Emacs: Repeat Last Command
- Emacs: Jump to Previous Position
- Emacs: Narrow to Region