vim中使用宏

发布时间:2021-07-26 23:32:58 阅读:1861次

前不久在做一个问卷调查,二货同事在表单控件没有加value

类似input type=checkbox

input type=radio

都没有加value,很多,发现vim中的宏派上用场

<input type=checkbox value="">
<input type=checkbox value="">
<input type=checkbox value="">
<input type=checkbox value="">
<input type=checkbox value="">
<input type=checkbox value="">
<input type=checkbox value="">
<input type=checkbox value="">
<input type=checkbox value="">
<input type=checkbox value="">

一、

光标移动到第一行

$                 ctrl+v             j                 shift + i               value="1"                 ESC

二、

光标移动到第一行

:let i=1

qa           ^            f"            a            ctrl+r         =i              ESC           :let i +=  1          $             j                   q

shift+v             :'<,'>normal @a

<input type=checkbox value="1">
<input type=checkbox value="2">
<input type=checkbox value="3">
<input type=checkbox value="4">
<input type=checkbox value="5">
<input type=checkbox value="6">
<input type=checkbox value="7">
<input type=checkbox value="8">
<input type=checkbox value="9">
<input type=checkbox value="10">

相反操作

想将value=""这些去掉

光标移动到第一行

qa             ^            f"             l             v           /"enter        h           x            $             j            q 

shift+v             :'<,'>normal @a


the first line

the second line

the third line

the fourth line

the fifth line

the sixth line

我们想在

第一行加上1)

第二行加上2)

第三行加上3)

第四行加上4)

第五行加上5)

第六行加上6)

使用宏来操作

vim hong.txt

the first line

the second line

the third line

the fourth line

the fifth line

the sixth line

第一步

:let i=1

qa

 i      ctrl+r      =i       回车键   )  ESC

:let     i    +=    1

q

第二步

jVG

:'<,'>normal @a

编辑宏

将编辑的内容添加到宏

如有问题,可以QQ搜索群1028468525加入群聊,欢迎一起研究技术

支付宝 微信

有疑问联系站长,请联系QQ:QQ咨询

转载请注明:vim中使用宏 出自老鄢博客 | 欢迎分享