Editing macros

Macros are stored in registers (the same ones used by yank and paste operations). You can view the contents of all your registers by executing :reg:

Close to the middle of the list you can see "a, the register containing our macro. You can also view the contents of, say, register a by executing :echo @a.

In the preceding screenshot, many special characters are represented differently. For instance, ^[ signifies the Esc key, and ^M is an Enter key.

In fact, macros are nothing but registers: the q command lets you add keystrokes to the register, while @ lets you replay the keystrokes from that register.

Since the macro is just a register, you can paste it using p. Open a new buffer with :new, and paste the contents of the register using "ap:

Now you can edit your macro without having to retype the whole thing.

When you're finished editing, copy it back into the register: _"ay$. _ will place you to the beginning of the line, "a will tell yank to use register a, and y$ will copy the text until the end of the line.

That's it. Paste the register with "ap, and place it back when you've finished editing using _"ay$.

As with many Vim commands, you shouldn't try to remember the exact letters, but focus on what the command does. This one, for instance, goes to the beginning of the line and yanks the rest of the line into register a. That's much easier to remember than _"ay$.
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.136.18.48