VIM宏编辑
假设我录制了一个很长的宏,其中包含许多命令和特殊字符。我很可能在某个地方犯了错误:) 如何编辑宏、更正错误并再次保存?
例如:
我想复制一行,然后将其中的数字加一。
这个宏是,
yyp/\d<C-A>
但它被保存为
yyp/\d^M^A
,当我粘贴寄存器时我看不到这个特殊字符。当我想要复制寄存器时,我还必须使用“let”,因为标准粘贴到屏幕并复制到另一个寄存器不起作用。如何有效地编辑带有特殊字符的寄存器?
谢谢
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
当您说“看不到特殊字符”时,您是什么意思?什么特殊字符?您应该能够看到; 分别。这就是你所需要的。
^A
和^M
,它们代表
和因此,只需将寄存器粘贴到缓冲区中即可。然后编辑并拉回寄存器并作为普通宏执行。如果您想将
编辑为其他内容,例如
,那么只需删除该^A
显示在粘贴上,并通过按
放入
(或
(如果您使用的是 Windows 且启用了 Windows 兼容性)。它将显示为^E
,但这就是它应该的样子。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.在插入模式下按
q
(这里q是寄存器名称)。执行:h ctrl-r_ctrl-r
查看详细信息。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.