2

I don't know the name of the command C-<number> <entry> to repeat the <entry>, <number> times.

For me it is more annoying than useful, several times I have accidentally introduced 88888 times an asterisk, because my finger hits the Ctrl key instead of the Shift.

Is there a way to disable this repetition command unless I directly type C-u <number> <entry>?

1 Answer 1

2

The command you are looking for is digit-argument. It is bound to C-9, C-8, C-7, C-6, C-5, C-4, C-3, C-2, C-1, C-0, ESC 0..9, C-M-9, C-M-8, C-M-7, C-M-6, C-M-5, C-M-4, C-M-3, C-M-2, C-M-1, and C-M-0.

I don't recommend that you remove such bindings. But if you want to you can remove each like this:

(global-set-key (kbd "C-0") nil)
(global-set-key (kbd "C-1") nil)

etc.

5
  • thanks, why don't you recommend it?
    – onlycparra
    Nov 19, 2018 at 3:21
  • Many Emacs commands make use of numeric arguments, either to repeat an action (e.g. C-5 C-n to move down five lines) or to alter the default behavior of the command in some way. They are used frequently enough that you'll notice the default key bindings let you enter a numeric argument with any combination of C- and M- modifiers -- that way whatever key binding you're about to hit can be provided an argument without changing modifiers.
    – glucas
    Nov 19, 2018 at 4:30
  • 1
    Note that the numeric argument doesn't always mean 'repeat'. For example, C-2 C-y will yank the second-to-last kill. M-2 M-s o will show lines matching a pattern (occur) but with two lines of context around each match. Some commands have special behavior for 0 or 1 as an argument... Anyway, the point some Emacs users rely heavily on numeric arguments!
    – glucas
    Nov 19, 2018 at 4:50
  • 1
    I don't recommend it because I don't recommend messing with prefix-arg key bindings. No special reason, though. If such keys get in your way, go for it.
    – Drew
    Nov 19, 2018 at 4:52
  • Sometimes I meant to open parenthesis to put a very big number, but instead of shift, I press ctrl, then I realize it is not typing, so enter one parenthesis "again", and boom: emacs is now writing millions of parenthesis and eating all my ram. How could I avoid this? (besides learning to type better)
    – onlycparra
    Jun 30, 2021 at 22:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.