Post

Vim Macros with Macrobotics Plugin

Vim Macros are great for reducing repetitive keystrokes and speeding up your web development code editing processes. By default the Vim Macro process is a little fiddly. Using the Macrobiotics plug-in helps make the macro process a little easier.

Here we clean up a convoluted HTML document using some repeatable VM commands which makes the process of cleaning up the document a lot easier. Firstly we activate the macro recording using gq and then we use our VM command of delete surrounding tags with the dst keys now it’s time to end the recording so we can do this with gq. Now because we want to repeat this command many times throughout this convoluted document we can simply repeat the last macro with the . key.

delete surrounding html tags automatically with vim macros

Prerequisites

Vim Macrobotics plugin installed more info

Basic Usage

Start Recording New Macro

1
gq

End Recording Macro

1
gq

Playback Last Recording

1
q

Playback Last Recording Multiple Times

1
30q
This post is licensed under CC BY 4.0 by the author.

Comments powered by Disqus.