vim macro allows you to record a sequence of commands that you use to perform a given task. You then execute that macro many times to repeat the same job in an automated way.
[ESC] q <a letter> (vim will inform you “recording @[ESC] qWrapping paragraph of PL/SQL code with BEGIN END; lines;
Before:
DBMS_OUTPUT.PUT_LINE(SYSDATE);
After:
BEGIN
DBMS_OUTPUT.PUT_LINE(SYSDATE);
END;
[ESC] q s (the letter for the macro will be s)Place the cursor on the paragraph.
Start recording by [ESC] q s (vim will inform you”recording @s”
Type the following sequence: {oBEGIN[ESC]}OEND;[ENTER][ESC].
let’s break it down…
{ will get us a line before the paragrapho will add a new line and will get us to insert mode in that line.BEGIN
[ESC] for command mode
* Type } to move to the end of the paragraphO this will change the mode to insert modeEND; and [ESC]on command mode type [ESC] q
Place your cursor on another paragraph
On command mode type @s
Applying the macro multiple times (for example 7 times) can be done by typing 7@s.