本文介绍了保存vim宏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有人知道如何正确保存/重用vim编辑器中记录的宏吗?
Does anyone know how to properly save/reuse macros recorded inside of a vim editor?
推荐答案
使用q
后跟一个字母来记录宏.这只是进入复制/粘贴寄存器之一,因此您可以在正常模式下使用"xp
或"xP
命令像往常一样将其粘贴.
Use q
followed by a letter to record a macro. This just goes into one of the copy/paste registers so you can paste it as normal with the "xp
or "xP
commands in normal mode.
要保存该文件,请打开.vimrc并粘贴内容,然后该寄存器将在下次启动vim时出现.
格式类似于:
To save it you open up .vimrc and paste the contents, then the register will be around the next time you start vim.
The format is something like:
let @q = 'macro contents'
但是请小心引号.他们必须被适当地逃脱.
Be careful of quotes, though. They would have to be escaped properly.
因此,要保存宏,您可以执行以下操作:
So to save a macro you can do:
- 在正常模式下:
qq
- 输入任何命令
- 在正常模式下:
q
- 打开.vimrc
-
"qp
将宏插入您的let @q = '...'
行
- From normal mode:
qq
- enter whatever commands
- From normal mode:
q
- open .vimrc
"qp
to insert the macro into yourlet @q = '...'
line
这篇关于保存vim宏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!