
- Vim Tutorial
- Vim - Home
- Vim - Introduction
- Vim - Installation & Configuration
- Vim - It’s friends
- Vim - Getting familiar
- Vim - Getting help
- Vim - Editing
- Vim - Navigating
- Vim - Revisiting Editing
- Vim - Searching
- Vim - Working With Multiple Things
- Vim - Markers
- Vim - Macros
- Vim - Registers
- Vim - Folding
- Vim - Diff
- Vim - Plug-ins
- Vim - Using Vim as IDE
- Vim - Remote File Editing
- Vim - Tips & Tricks
- Vim - Personalization
- Vim - Conclusion
- Vim Useful Resources
- Vim - Quick Guide
- Vim - Useful Resources
- Vim - Discussion
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Vim - Macros
Macro is record and play feature. When this is combined with Vim commands it becomes really powerful combination. In this section, we will discuss following items −
- Start recording
- Perform Vim actions
- Stop recording
- Play recording
Start recording
To start recording press q followed by any lower case letter as a macro name. For instance in below example I have used “a” as a macro name

Perform Vim actions
In this step you can perform any Vim actions like: cut, copy, delete, replace and so on.You can see these actions by executing following command −
:registers
For instance, below command shows that yank and delete actions were performed −

Stop recording
Once you are done with actions, press q again to stop recording. Now recording mode will disappear as shown below −

Play
To play execute below command −
@{macro-name}
For instance to execute macro “a”, execute below command −
@a
To play same macro multiple times use numbers with it. For instance, to execute same macro 10 times execute following command −
10@a