音频应用   音频插件联盟,正版插件,欢迎大家选择!

 找回密码
 快速注册

QQ登录

只需一步,快速开始

阅读: 10124|回复: 1

[资讯] vim recording的使用方法

[复制链接]

1712

积分

2

听众

-16

音贝

音频应用新手发布

Rank: 3

积分
1712
发表于 2006-1-8 | |阅读模式
音频应用公众号资讯免费发布推广
使用vim时无意间触碰到q键,左下角出现“recording”这个标识,觉得好奇,遂在网上查了一下,然后这是vim的一个强大功能。他可以录 制一个宏(Macro),在开始记录后,会记录你所有的键盘输入,包括在insert模式下的输入、正常模式下使用的各种命令等。

具体使用:

第一步:在正常模式下(非insert模式、非visual模式)按下q键盘

第二步:选择a-z或0-9中任意一个作为缓冲器的名字,准备开始录制宏

第三步:正常的操作,此次所有的操作都会被记录在上一步中定义的缓冲器中

第四步:在非insert模式下输入q停止宏的录制

第五步:使用@ + 第二步中定义的缓冲器的名字即可。



例如想把下面的文字

1

2

3

4


[color=rgb(255, 128, 0) !important]line1
[color=rgb(189, 183, 107) !important]line[color=rgb(218, 218, 218) !important]-[color=rgb(231, 163, 122) !important]2
[color=rgb(189, 183, 107) !important]line3[color=rgb(218, 218, 218) !important]-[color=rgb(231, 163, 122) !important]1
[color=rgb(189, 183, 107) !important]l4



变成如下的文字

1

2

3

4

5


[color=rgb(189, 183, 107) !important]System[color=rgb(216, 216, 216) !important].[color=rgb(189, 183, 107) !important]out[color=rgb(216, 216, 216) !important].[color=rgb(255, 128, 0) !important]println[color=rgb(216, 216, 216) !important]([color=rgb(189, 183, 107) !important]line1[color=rgb(216, 216, 216) !important])[color=rgb(216, 216, 216) !important];
[color=rgb(189, 183, 107) !important]System[color=rgb(216, 216, 216) !important].[color=rgb(189, 183, 107) !important]out[color=rgb(216, 216, 216) !important].[color=rgb(255, 128, 0) !important]println[color=rgb(216, 216, 216) !important]([color=rgb(189, 183, 107) !important]line1[color=rgb(216, 216, 216) !important])[color=rgb(216, 216, 216) !important];
[color=rgb(189, 183, 107) !important]System[color=rgb(216, 216, 216) !important].[color=rgb(189, 183, 107) !important]out[color=rgb(216, 216, 216) !important].[color=rgb(255, 128, 0) !important]println[color=rgb(216, 216, 216) !important]([color=rgb(189, 183, 107) !important]line[color=rgb(218, 218, 218) !important]-[color=rgb(231, 163, 122) !important]2[color=rgb(216, 216, 216) !important])[color=rgb(216, 216, 216) !important];
[color=rgb(189, 183, 107) !important]System[color=rgb(216, 216, 216) !important].[color=rgb(189, 183, 107) !important]out[color=rgb(216, 216, 216) !important].[color=rgb(255, 128, 0) !important]println[color=rgb(216, 216, 216) !important]([color=rgb(189, 183, 107) !important]line3[color=rgb(218, 218, 218) !important]-[color=rgb(231, 163, 122) !important]1[color=rgb(216, 216, 216) !important])[color=rgb(216, 216, 216) !important];
[color=rgb(189, 183, 107) !important]System[color=rgb(216, 216, 216) !important].[color=rgb(189, 183, 107) !important]out[color=rgb(216, 216, 216) !important].[color=rgb(255, 128, 0) !important]println[color=rgb(216, 216, 216) !important]([color=rgb(189, 183, 107) !important]L4[color=rgb(216, 216, 216) !important])[color=rgb(216, 216, 216) !important];




观察可以发现他们的规律,在每行文字的开头添加“System.out.println(”,结尾添加“);”就变成下面的信息了。下面简单介绍一下如何使用recording来完成这样的操作。
首先把光标移动line1上,输入qt,准备开始录制,缓冲器的名字为t,录制的动作为:shift + ^ 回到行首、按下i键进入insert模式、输入“System.out.println(”、按下esc键回到正常模式、shift + $ 回到行尾部、按下i键进入insert模式、输入“);”按下esc键回到正常模式,按下q停止录制。然后把光标移动到下面一行的任意位置输入 @ + t 即可。

recording还可以和查询结合起来使用,例如想把一个文件中含有特定字符串的行注释,可以通过这样的宏来实现。在正常模式下输入/search string + enter、shift + ^、i、#、esc、shift + $。

让定制的宏自动执行多次的方法是先输入一个数字,然后在输入@ + 缓冲器的名字。 例如 100@t,表示执行100次。
电子琴

5291

积分

3

听众

-727

音贝

音频应用注册会员

Rank: 4Rank: 4

积分
5291
发表于 2006-1-8 |
分享。路过,点赞了啊
欢迎厂家入驻,推文!免费!微信:yinpinyingyong
您需要登录后才可以回帖 登录 | 快速注册

本版积分规则

音频应用搜索

小黑屋|手机版|音频应用官网微博|音频招标|音频应用 (鄂ICP备16002437号)

Powered by Audio app

快速回复 返回顶部 返回列表