我似乎无法创建一个vim宏来实现以下操作:
源代码:
this_is_a_bus[10:0]
another_bus[2:0]
需要目标:
this_is_a_bus[10]
this_is_a_bus[9]
this_is_a_bus[8]
this_is_a_bus[7]
this_is_a_bus[6]
this_is_a_bus[5]
this_is_a_bus[4]
this_is_a_bus[3]
this_is_a_bus[2]
this_is_a_bus[1]
this_is_a_bus[0]
another_bus[2]
another_bus[1]
another_bus[0]
我试图做的事情: 我可以搜索
\d\+:\d\+
,并将光标放在第一个数字上,然后使用 yw
将其复制到内存中。但是我似乎无法告诉 Vim 根据寄存器中的数字运行粘贴命令。我是不是走错了路?有什么建议的方法来创建这样的东西吗?
[10:3]
,[20:1]
,[8:5]
等等。虽然vim肯定可以做到,但这是必须的吗?awk或其他脚本语言可以更容易地实现。 - Kent