Often a prefix argument just performs an action multiple times, so you'd expect C-u 10 C-y to work, but in this case C-y uses its argument to mean which element of the kill-ring to "yank" (paste). The only solution I can think of is what kronoz says: record a macro with C-x ( C-y C-x ) and then let the argument of C-u go to kmacro-end-and-call-macro instead (that's C-u 9 C-x e or even just C-9 C-x e or M-9 C-x e).

Another way:
You can also just stay in M-x viper-mode and use yy10p :)

Note that since the release of Emacs 22.1 you can actually use <C-S-backspace> which runs kill-whole-line and is the equivalent of dd in vi. So whenever you find yourself doing C-a C-k C-k you can just <C-S-backspace>.
–
Deniz DoganMay 19 '11 at 12:25

You may know this, but for many commands a "C-u 10" prefix will do the trick. Unfortunately for the C-y yank command, "C-u" is redefined to mean "go back that many items in the kill ring, and yank that item".

I thought you might be able to use the copy-to-register and insert-register commands with the C-u prefix command, but apparently that doesn't work either.

Also C-x z, "repeat last command" seems to be immune to C-u.

Another thought would be to use M-: to get an Eval prompt and type in a bit of elisp. I thought something like (dotimes '10 'yank) might do it, but it doesn't seem to.

So it looks like using C-u on a macro may indeed be the best you can do short of writing your own little function.

You can just give the repeat argument straight to C-x ). This stops recording and repeats the macro, in one step. Or you can skip C-x ) and go straight to C-x e, since C-x e will end the recording before doing the repeats.

Which way to choose depends on how you like your repeat count to work. For C-x ) you say how many repeats you wanted in total (so 10 in this case). For C-x e you need to say how many more repeats are left (i.e. 9).

C-a C-k C-k will also kill the trailing newline, so you don't have to put it back yourself later. It's quicker than using the mark, and doesn't need you to change any variables.

Even better (unless you're in a terminal), you can use C-S-Backspace* to kill the entire line, regardless of where you are in it.

[* If you're using X windows, make sure to type shift (not alt) or you may terminate your session!]

Speaking of terminals, M-9 is a nice alternative if you find you can't type C-9.

In Emacs 22 and higher, by default F3 starts a macro and F4 end/repeats a macro. You just hit F3 to start recording, hit F4 when you're done, and hit F4 again to repeat the macro. (F4 also takes an argument.)

Nice guess, but did you actually try it out? The C-u prefix command selects which element from the kill ring to yank when used in combo with C-y. It does not repeat the command 10 times.
–
BaxissimoSep 17 '08 at 9:39