Difference between revisions of "Recording macros in vim"

From Notes_Wiki
(Created page with "<yambe:breadcrumb>Vim|Vim</yambe:breadcrumb> =Recording macros in vim= It is possible to record a sequence of action in vim as a macro and then play it later to achieve the s...")
 
m
 
(One intermediate revision by the same user not shown)
Line 1: Line 1:
<yambe:breadcrumb>Vim|Vim</yambe:breadcrumb>
[[Main Page|Home]] > [[CentOS]] > [[CentOS 6.x]] > [[Text editors]] > [[Vim]] > [[Recording macros in vim]]
=Recording macros in vim=


It is possible to record a sequence of action in vim as a macro and then play it later to achieve the same result.  
It is possible to record a sequence of action in vim as a macro and then play it later to achieve the same result.  
Line 19: Line 18:


Once a macro is recorded it can be played using '@&lt;alphabet&gt;' key combination in normal mode where &lt;alphabet&gt; is the single letter alphabet where the recording was stored. The same macro can be played many times by using vim's repeat syntax '&lt;number&gt;@&lt;alphabet&gt;'
Once a macro is recorded it can be played using '@&lt;alphabet&gt;' key combination in normal mode where &lt;alphabet&gt; is the single letter alphabet where the recording was stored. The same macro can be played many times by using vim's repeat syntax '&lt;number&gt;@&lt;alphabet&gt;'
[[Main Page|Home]] > [[CentOS]] > [[CentOS 6.x]] > [[Text editors]] > [[Vim]] > [[Recording macros in vim]]

Latest revision as of 15:50, 24 August 2022

Home > CentOS > CentOS 6.x > Text editors > Vim > Recording macros in vim

It is possible to record a sequence of action in vim as a macro and then play it later to achieve the same result.


Recording macro

To record a macro use following steps:

  • Change mode to normal mode, if not already.
  • Press 'q' to start recording
  • Press a single letter alphabet to store the recoding into, eg 'a'
  • Perform actions that should be recorded
  • If at the end of actions you are not in normal mode than press 'Esc' to go to normal mode
  • Press 'q' to stop recording


Playing macro

Once a macro is recorded it can be played using '@<alphabet>' key combination in normal mode where <alphabet> is the single letter alphabet where the recording was stored. The same macro can be played many times by using vim's repeat syntax '<number>@<alphabet>'


Home > CentOS > CentOS 6.x > Text editors > Vim > Recording macros in vim