5

Suppose that I have recorded a long macro with many commands and special characters. Odds are I have made an error somewhere :) How can I edit a macro, correct errors and save it again?

For example:

I wish to copy a line and then increase the digit in it by one.

Macro for this is

yyp/\d<C-A>

but it is saved as

yyp/\d^M^A

and I can't see this special characters when I paste the register. I also have to play with 'let' when I wish to copy a register, because standard paste to screen and copy to another register doesn't work. How can I efficiently edit register with special characters?

Thanks

shime
  • 8,746
  • 1
  • 30
  • 51

2 Answers2

5

What do you mean when you say you "can't see the special characters"? What special characters? You should be able to see the ^A and ^M fine, which represent <C-A> and the <carriage return> respectively. That's all you need.

So do just paste the register into a buffer. Then edit and yank back into a register and execute as a normal macro. If you want to edit the <C-A> to be something else, say, <C-E>, then just delete the ^A that shows up on paste and put a <C-E> in by pressing <C-V><C-E> (or <C-Q><C-E> if you're on Windows with windows compatibility on). It will show up as ^E, but that's how it's supposed to be.

Herbert Sitz
  • 21,858
  • 9
  • 50
  • 54
  • Oh my, thanks for this. The problem was my pasting of register when I was in insert mode, so I couldn't see this ^M and ^A. – shime Jun 30 '11 at 17:37
0

Press <C-r><C-r>q (here q is the register name) in insert mode. Execute :h ctrl-r_ctrl-r to see the details.

Hongbo Liu
  • 2,818
  • 1
  • 24
  • 18