VIM宏编辑 [英] VIM macro editing

查看:40
本文介绍了VIM宏编辑的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设我录制了一个包含许多命令和特殊字符的长宏.可能是我在某处出错了:)如何编辑宏,更正错误并再次保存?

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?

例如:

我希望复制一行,然后将其中的数字增加一个.

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

这是宏

yyp/\d<C-A>

,但另存为

yyp/\d^M^A

,粘贴寄存器时看不到这些特殊字符.当我希望复制寄存器时,我还必须使用let",因为标准粘贴到屏幕并复制到另一个寄存器不起作用.如何有效地编辑带有特殊字符的寄存器?

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?

谢谢

推荐答案

当您说看不到特殊字符"是什么意思?什么特殊字符?您应该能够很好地看到 ^ A ^ M ,它们分别表示< C-A> <回车> .这就是您所需要的.

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.

因此,只需将寄存器粘贴到缓冲区中即可.然后编辑并拉回到寄存器中,并作为普通宏执行.如果您想将< C-A> 编辑为其他名称,例如< C-E> ,则只需删除 ^ A ,然后按< C-V>< C-E> (或< C-Q>< C-E> (如果您使用的是Windows且具有Windows兼容功能).它会显示为 ^ E ,但这就是应该的样子.

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.

这篇关于VIM宏编辑的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆