Ads by Google

Sunday, October 14, 2007

Repeating Numbers in Emacs

With the universal prefix, ' C-u', it's possible to repeat text, either the default 4 times or with numeric arguments 'n', n times.

C-u 1 0 #

will give you 10 #s.

What if you want 10 1s?

C-u 1 0 1

only specifies a 101 repeat sequence.

A quick peek at the manual reveals the answer.

`C-u 6 4 a' inserts 64 copies of the character `a'. But this does not work for inserting digits; `C-u 6 4 1' specifies an argument of 641. You can separate the argument from the digit to insert with another `C-u'; for example, `C-u 6 4 C-u 1' does insert 64 copies of the character `1'.

So the answer is 'C-u 1 0 C-u 1'.

Emacs has all the answers, you need to ask the right questions. :-)

No comments: