15

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.

dalanicolai
  • 6,108
  • 7
  • 23
dbjergaard
  • 153
  • 4

2 Answers2

23

C-u 6 C-u 2

Documentation for universal-argument (emphasis mine):

Begin a numeric argument for the following command.
Digits or minus sign following C-u make up the numeric argument.
C-u following the digits or minus sign ends the argument.
C-u without digits or minus sign provides 4 as argument.
Repeating C-u without digits or minus sign
multiplies the argument by 4 each time.
For some commands, just C-u by itself serves as a flag
which is different in effect from any particular numeric argument.
These commands include C-SPC and M-x start-kbd-macro.

You can find this documentation by typing C-h k C-u or M-x describe-function RET universal-argument RET.

nanny
  • 5,704
  • 18
  • 38
4

Your question title doesn't match the body text?

If you want to "repeat a number" (singular), nanny's answer has you covered.

If (as per the title) you want to "repeat a list of numbers", I would use a keyboard macro. e.g.:

<f3> 12345 C-u6<f4>

phils
  • 48,657
  • 3
  • 76
  • 115