Duplicate tip
This tip is very similar to the following:
These tips need to be merged – see the merge guidelines.
If you recorded a keyboard macro, but did not get it quite right, you can actually make changes to that recorded macro.
Here is how.
First, see Vim macros for most of what you need to know about recording and using macros.
Now, suppose that you have recorded your macro in register "a. While in normal mode do the following:
1. Type:
:let @a='
2. Press Ctrl-R then "a" to insert the previous contents of register "a.
3. Edit and modify it, then close the quote.
4. Press return.
Use ":registers" to view the new value in that register.
Use "@a" to execute the contents of register "a.
Comments
This is actually mentioned in passing, in the Macros page linked above. Near the bottom, it talks about adding a macro to your .vimrc using this same method. Note, however, that the Macros tip uses CTRL-R_CTRL-R instead of just a single CTRL-R so that the contents of the macro are inserted literally, instead of "as typed". This means, for example, that you will get any backspaces, arrow keys, etc. exactly as typed into the new macro, instead of Vim interpreting the backspace/arrow/whatever as the text is placed on the command line. --Fritzophrenic 17:29, July 21, 2011 (UTC)