开发者

VIM macro editing

开发者 https://www.devze.com 2023-03-16 02:46 出处:网络
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?

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, becaus开发者_Go百科e standard paste to screen and copy to another register doesn't work. How can I efficiently edit register with special characters?

Thanks


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.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消