Difference between revisions of "Keyboard macros"

From WikEmacs
Jump to navigation Jump to search
(converse støvler til børn converse støvler vibram fivefingers rnde)
m (Protected "Keyboard macros": Excessive spamming ([Edit=Allow only autoconfirmed users] (expires 22:13, 23 September 2014 (UTC)) [Move=Allow only autoconfirmed users] (expires 22:13, 23 September 2014 (UTC))))
(116 intermediate revisions by 41 users not shown)
Line 1: Line 1:
Le grand pyrénéiste Henry Russell appellera plus tard le Balaïtous  le Cervin des Pyrénées .  ÿþ<> Nous avons essayé de commercialiser ce dispositif efficace pour le VTT de descente, mais son coût restait trop élevé pour le marché , constate Eric Barone.. And if you decide to get adventurous and tackle a more advanced trail, you want to make sure your hiking shoe doesn't leave you slipping and tripping.. 
+
{{Manual|emacs|Basic-Keyboard-Macro|Basic Keyboard Macro}}
  
Chinée en août  état neuf, tout de même !  dans un videgrenier de campagne, on raffole de sa Seb orange seventies ou de sa Yalacta (plus rare, plus smart), pour produire ses yaourts home made. Arriv au ravito, C nous surprend avec son objectif.  ÿþ<> Last vibram shoes slightly had the fame jewelry processing shop to receive the vibram, but declared repeatedly, even if has fixed, also will no longer be the original appearance will vibram jewelery still leave behind the scar, this to the attractive vibram is the how brutal fact! But lets the vibram feel what is gratified is the master has not Vibram Five Fingers US Sale abandoned it, has fixed it, has returned in the brocade box.
+
'''Keyboard macros''' can be used to automate or repeat tedious editing tasks in Emacs.
ÿþh
+
 
Et d'ajouter : "Je dis, ne jouez pas les durs.". Après 68, on a commencé à considérer la marche non plus comme une activité hygiénique mais comme un plaisir, une jouissance de tous les sens." Dans le sillon d'un Jacques Lacarrière ou d'un Jacques Lanzmann, Paccalet accomplit à travers la marche une oeuvre littéraire, esthétique et sensuelle. Elles stimulent le pied, renforcent les muscles et la posture et aident à améliorer l'agilité, l'équilibre et le sentiment de contrôle. Ensuite quelqu'un vient vous masser très énergiquement le haut du dos et les épaules. ÿþ<> Children 13 years old and younger are not permitted at this adultsonly property. Et on prend le temps, au lieu que ce soit le temps qui nous prenne." Julie Gospaurd ne conçoit pas de vivre loin de son terrain de jeu favori: la montagne  "La plaine, que c'est morne!" A 23 ans, elle use ses souliers dans les sentiers caillouteux et ses raquettes dans la neige des sommets.  
+
 
+
==Basic Use==
C'est déjà énorme.. Vous pouvez vous préparer en achetant COCA en homéopathie et biensur de prendre de l'aspirine au cas où. ÿþ<> and also fort et même l'amélioration des performances tout en réduisant le fonctionnement même accident.
+
 
ÿþh
+
; {{Keys|F3}}, or {{Keys|C-x (}}
<>]. The snug fit and good arch support left my feet feeling great after full days of hiking some rough terrain, walking around my neighborhood or even just following my wife around the mall. Samedi, petit matin, après une petite poignée d'heure de sommeil, il est là ÿþ<> Mit Sicherheit eine gute Wahl! Dieser Klassiker unter den Multifunktionsschuhen bietet dank eines stabilen Schafts aus 1,6 mm Nubukleder und einer innovativen Sohlenkonstruktion ein weites Einsatzspektrum und eignet sich hervorragend für Wanderungen auf befestigten Wegen und Pfaden. For the first time ever, Vibram introduces a stitchfree, seamless 2mm footbed to reduce friction. En plus d'être une mine de calcium, c'est top pour l'équilibre acidobasique.
+
: Start defining a macro.
 +
; {{Keys|F4}}, or {{Keys|C-x )}}
 +
: Stop defining a macro.
 +
; {{Keys|F4}}, or {{Keys|C-x e}}
 +
: Execute a macro
 +
; {{Keys|C-u 37 C-x e}} or {{Keys|C-u 37 F4}}
 +
: Execute a macro multiple times, using [[prefix argument]]
 +
; {{Keys|C-u 0 C-x e}}
 +
: Execute a macro until the end of the buffer
 +
 
 +
==Example usage==
 +
Consider the standard <code>*scratch*</code> buffer:
 +
 
 +
<pre>
 +
;; This buffer is for notes you don't want to save, and for Lisp evaluation.
 +
;; If you want to create a file, visit that file with C-x C-f,
 +
;; then enter the text in that file's own buffer.
 +
</pre>
 +
 
 +
Suppose you want to remove the first occurrence of the letter "a" on every row in that piece of text. You could write a [[regular expression]] to do the job, but let's assume you want to use a keyboard macro this time.
 +
 
 +
# Make sure [[point]] is at the start of the buffer.
 +
# Hit <code>C-x (</code> to start recording your macro. '''Note:''' If you hit <code>C-g</code> or if an error occurs, your keyboard macro recording will stop.
 +
# Hit <code>C-s</code> followed by <code>a</code> to find the first "a". Now, point is right after the first "a" in the text.
 +
# Hit backspace to delete that "a".
 +
 
 +
The first occurrence of "a" of the first line has been deleted. Let's move point to the beginning of the next line and then stop recording.
 +
 
 +
<ol start="5">
 +
<li>Hit <code>C-e C-f</code> to move point to the beginning of the next line.</li>
 +
<li>Hit <code>C-x )</code> to finish the recording of our macro.</li>
 +
</ol>
 +
 
 +
The macro you have just recorded performs the operation of removing the first occurrence of "a" it can find and then moving point to the next line.
 +
 
 +
<ol start="7">
 +
<li>Hit <code>C-x e</code> once to call that macro.</li>
 +
<li>Continue hitting <code>e</code> to call it several times. Hit any other key to get out of the macro repetition.</li>
 +
</ol>
 +
 
 +
==Saving macros==
 +
{{Manual|emacs|Save-Keyboard-Macro|Save Keyboard Macro}}
 +
 
 +
===Binding to a key===
 +
To bind a keyboard macro to a key use <code>C-x C-k b</code>. To avoid problems caused by overriding existing bindings, the key sequences <code>C-x C-k 0</code> through <code>C-x C-k 9</code> and <code>C-x C-k A</code> through <code>C-x C-k Z</code> are reserved for your own keyboard macro bindings. You can, however, bind a keyboard macro to whatever you like.
 +
 
 +
==Variables==
 +
 
 +
Variables can be stored in lisp or in [[registers]]Here's an example using lisp:
 +
 
 +
<pre>
 +
[M-: (setq x 1)]
 +
<F3>
 +
Line number [C-u M-: x]
 +
[M-: (setq x (+ x 1))]
 +
<F4>
 +
</pre>
 +
 
 +
Now execute the macro four times with the command <code>C-x e e e e</code> and you get:
 +
 
 +
line number 1<br />
 +
line number 2<br />
 +
line number 3<br />
 +
line number 4

Revision as of 22:13, 23 March 2014

Basic Keyboard Macro (`(info "(emacs) Basic Keyboard Macro")')

Keyboard macros can be used to automate or repeat tedious editing tasks in Emacs.


Basic Use

[F3], or [C-x (]
Start defining a macro.
[F4], or [C-x )]
Stop defining a macro.
[F4], or [C-x e]
Execute a macro
[C-u 37 C-x e] or [C-u 37 F4]
Execute a macro multiple times, using prefix argument
[C-u 0 C-x e]
Execute a macro until the end of the buffer

Example usage

Consider the standard *scratch* buffer:

;; This buffer is for notes you don't want to save, and for Lisp evaluation.
;; If you want to create a file, visit that file with C-x C-f,
;; then enter the text in that file's own buffer.

Suppose you want to remove the first occurrence of the letter "a" on every row in that piece of text. You could write a regular expression to do the job, but let's assume you want to use a keyboard macro this time.

  1. Make sure point is at the start of the buffer.
  2. Hit C-x ( to start recording your macro. Note: If you hit C-g or if an error occurs, your keyboard macro recording will stop.
  3. Hit C-s followed by a to find the first "a". Now, point is right after the first "a" in the text.
  4. Hit backspace to delete that "a".

The first occurrence of "a" of the first line has been deleted. Let's move point to the beginning of the next line and then stop recording.

  1. Hit C-e C-f to move point to the beginning of the next line.
  2. Hit C-x ) to finish the recording of our macro.

The macro you have just recorded performs the operation of removing the first occurrence of "a" it can find and then moving point to the next line.

  1. Hit C-x e once to call that macro.
  2. Continue hitting e to call it several times. Hit any other key to get out of the macro repetition.

Saving macros

Save Keyboard Macro (`(info "(emacs) Save Keyboard Macro")')

Binding to a key

To bind a keyboard macro to a key use C-x C-k b. To avoid problems caused by overriding existing bindings, the key sequences C-x C-k 0 through C-x C-k 9 and C-x C-k A through C-x C-k Z are reserved for your own keyboard macro bindings. You can, however, bind a keyboard macro to whatever you like.

Variables

Variables can be stored in lisp or in registers. Here's an example using lisp:

[M-: (setq x 1)]
<F3>
Line number [C-u M-: x]
[M-: (setq x (+ x 1))]
<F4>

Now execute the macro four times with the command C-x e e e e and you get:

line number 1
line number 2
line number 3
line number 4