Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Emacs repeat string n times

Tags:

I'm learning the basics of navigating/editing in Emacs and I'm curious how one could accomplish the following task:

  • Repeat the string 'bla ' n times in normal text editing mode.

Let's say I want to repeat it five times to generate 'bla bla bla bla bla '. I tried...

C-u 5 bla 

...but the command executes after the 'b' is entered, and I only get 'bbbbb'.

I'm sure there's some basic command that can help me here...would somebody be kind enough to enlighten me :)?

like image 625
sammy34 Avatar asked Jul 27 '13 04:07

sammy34


People also ask

How to repeat last command Emacs?

The command C-x z ( repeat ) provides another way to repeat an Emacs command many times. This command repeats the previous Emacs command, whatever that was.

How do I repeat a macro in Emacs?

Immediately after typing C-x e , you can type e repeatedly to immediately repeat the macro one or more times. You can also give C-x e a repeat argument, just like F4 (when it is used to execute a macro).


1 Answers

One way is via a keyboard macro:

C-x (bla C-x)C-u4C-xe

You can also just insert the repeat count before the macro termination:

C-x (bla C-u5C-x)

like image 141
Keith Flower Avatar answered Nov 09 '22 12:11

Keith Flower