Questions tagged [prefix-argument]
51 questions
15
votes
2 answers
How to use a numeric prefix to repeat insertion of a digit?
Suppose I want to type '222222' in emacs, how do I use the numeric prefix idiom to achieve this? A naive guess would be 'C-u 6 2' but emacs interprets this as a numeric prefix of 62 and waits for the next command.

dbjergaard
- 153
- 4
13
votes
1 answer
How to apply `call-interactively` to an interactive command that accepts the universal argument?
I've read the documentation on how to make interactive calls from within Elisp, but I still can't figure out how to pass the universal argument when using call-interactively on a command that recognizes the universal argument.
More specifically, I…

kjo
- 3,145
- 14
- 42
12
votes
3 answers
What is a raw prefix argument? (capital P in interactive)
And what can they be used for?
(interactive "p") takes a numerical argument from the universal argument right? And the universal argument is just an int either way, so what does capital (interactive "P") do?

24HrRevengeTherapist
- 523
- 5
- 13
8
votes
1 answer
How to describe a key sequence that starts with `C-u`?
I am trying to use C-h k to describe the function to which a key is bound. But when I use it with a key chord like C-u C-e C-x it retrieves the documentation for C-u before I can finish typing the chord. What is the correct way to describe this type…

lookyhooky
- 949
- 7
- 18
8
votes
1 answer
How to pass a prefix argument to helm-m-x?
I have read the prefix has to be added after running helm-m-x, but I don't know how to do it.
For example I want to pass an argument to shell. When I run helm-m-x and then C-u I see in the mode-line [prefarg:4]. On the next key press there will be 4…

caisah
- 4,056
- 1
- 23
- 43
8
votes
3 answers
Swap default behavior of command with C-u behavior
Many Emacs commands alter their behavior when called with one or more C-u prefixes. In some cases the default behavior of a command is less useful to me than the behavior I get when prefixing it with C-u. At the same time, I do not want to get rid…

itsjeyd
- 14,586
- 3
- 58
- 87
6
votes
2 answers
Insert multiple minus ('-') characters using the universal argument (C-u)
I was manually creating a table in my source code's multiline comments
and inserting horizontal separators using - and =. E.g. C-u C-u C-u = as expected and inserts 64 =s at the point. But - is used to provide negative arguments and does not work in…

loonatick
- 217
- 1
- 5
6
votes
1 answer
How to rebind "special meaning" of C-u to a different key?
Excerpt from GNU Emacs manual:
C-u alone has the special meaning of “four times”:
it multiplies the argument for the next command by four.
C-u C-u multiplies it by sixteen.
Thus, C-u C-u C-f moves forward sixteen characters.
Is there a way to get…

Rogach
- 267
- 1
- 5
6
votes
3 answers
How to find out which function is bound to C-u C-SPC?
C-u C-SPC is used to
Move point to where the mark was, and restore the mark from the ring
of former marks.
When trying to get the function bound to C-u C-SPC with describe-key it just stops processing the query, with reason, in C-u and returns…

marcanuy
- 798
- 6
- 20
6
votes
2 answers
How to insert inactive [timestamp] via function?
C-u C-c ! generates a time stamp like [2015-05-04 Mon 17:13]
I would like to assign a shortcut (e.g F1) to this action.
So far I have:
(defun my/timenow (&optional arg)
(interactive)
(let ((current-prefix-arg 4)) ;; emulate C-u
(org-time-stamp…

Leo Ufimtsev
- 4,488
- 3
- 22
- 45
5
votes
2 answers
How to specify prefix argument in key binding
The description of C-x C-e mentions:
...Interactively, with a non '-' prefix argument, print output into current buffer.
I understand this to mean this logic is triggered when I issue C-u C-x C-e, but how would I bind this to C-c c? How do I…

young_souvlaki
- 526
- 2
- 13
5
votes
2 answers
Is there an easy way to detect how many `C-u`s a command was given?
I have made the following function to count how many C-u prefixes a command was given (assuming it is called interactively), but I feel this is a common-enough problem that there should be a built-in function (or a package that solves this problem…

Sean Allred
- 6,861
- 16
- 85
4
votes
2 answers
What is the difference between `C-u C-c C-l` and `C-c C-l`?
C-c C-l points to org-insert-link. In the minibuffer I am ask for a link type, link url and description.
But C-u C-c C-l shows me dired-like folder structure in the minibuffer and I can navigate to an (image) file and select it. That is nice.
I am…

buhtz
- 679
- 4
- 22
4
votes
1 answer
Using a number in register as prefix argument
How can I use a number in a register after C-u ?
For example my register looks like 1: 24, and I want to do C-u 24 x.

Faruk Akın
- 41
- 2
4
votes
3 answers
Use cases for M-0 & C-0?
The purpose of digit-argument and how to use them is described in Emacs manual.
Also read a question that asks how to disable them.
Even though have not disabled them, I have changed M-1, M-2, M-3 'cause I prefer to use them for…

nephewtom
- 2,219
- 17
- 29