Site Feed

Monday, December 7, 2009

How to Record and Play in Vim

Have you ever been in the middle of editing something in vim, and noticed "recording" on the lower left of the screen? If you were in a hurry, you probably just continued typing, and thought, maybe I'll use that feature some day, but as long as it lets me continue I won't worry about it. Well it's really quite simple to use once you know the sequence.

Here is a high level overview on how to use the macro recording feature of vim.

High Level Steps to Record and Play a Macro in Vim

1. Press q to Start recording, 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 a macro multiple times, press : n @ macro name, where n is a number.

For more details, check out a complete tutorial at Vim Macro Tutorial: How To Record and Play

No comments: