Emacs repeat string n times

眉间皱痕 提交于 2019-12-03 03:47:07

问题


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 :)?


回答1:


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)




回答2:


You can do it with keyboard macros: f3blaM-5 f4.

  1. f3 means "start recording"
  2. then you insert bla
  3. M-5 means "5 times"
  4. f4 means finish

Alternate to M-5 f4 is just f4 a bunch of times.



来源:https://stackoverflow.com/questions/17894167/emacs-repeat-string-n-times

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!