Vi and Vim Macros - Record and Play

by Sanju 2009-10-28 17:09:24

Record and Play inside Vim

         1. Start recording by pressing q, followed by a lower case character to name the macro

         2. Perform any typical editing, actions inside Vim editor, which will be recorded

         3. Stop recording by pressing q

         4. Play the recorded macro by pressing @ followed by the macro name

         5. To repeat macros multiple times, press

        
NN @ macro name


         NN is a number

Example:

In test.php

Welcome to the world of exciting free web design templates. Download free webdesign templates. Free Designer Templates is hosted in HIOXINDIA.


If you want to copy this line and want to paste it 100 times, follow the steps:

         1. After entering into test.php using vi test.php

         2. Start recording by pressing q, followed by the lower case r(any name)

         3. yy will copy the current line, p will paste the line that was just copied

         4. Stop recording by pressing q

         5. Play the record macro by pressing 100@p.

Tagged in:

1758
like
0
dislike
0
mail
flag

You must LOGIN to add comments