1. How to search for multiple keywords at the same time
For example, I want to highlight all aa, bbbb, ccccc
2.Example
There is an enum
enum Test {
TEST_A,
TEST_BBBBB,
TEST_CC,
TEST_DDDDDDD,
TEST_EEE
};
How to quickly add the following comments
enum Test {
TEST_A, // 0
TEST_BBBBB, // 1
TEST_CC, // 2
TEST_DDDDDDD, // 3
TEST_EEE // 4
};
For question 2, based on your answers and my own modifications, the method I use is as follows:
set ve=all
Allows the cursor to reach places without charactersC-v
Enter column block visual mode and select the column where you want to insert commentsA
and insert // 0
, press Esc
to return to normal modeV
Enter line visual mode and select all lines with added commentslet i=0|'<,'>g/0$/s//\=i/|let i=i+1
set ve=
Restore virtual editing options
第二个问题:
set ve=all
使得光标可以到达没有字符的地方C-v
进入列块可视模式,选中要插入注释的那一列A
并插入// 0
,按Esc
回到普通模式0
:I
把它改成递增的数值序列set ve=
把虚拟编辑选项复原(我推荐使用非默认值block
,这样不用经常切换了)PS: 一般用不到枚举的整数表示的吧?
第一个问题,搜索的时候用正则:
第二个问题,录制个宏就好了吧:
// 1
qq^f y$j$p^A
解释一下:
qq
: 录制宏到寄存器q
^
: 去行首f
: (注意f
后面是空格),去第一个空格处y$
: 复制到行尾j$p
: 去下一行的结尾粘贴^A
: (这是 Ctrl-A)+1第二个问题
使用
![](http://img.php.cn/upload/image/000/000/000/4811c749d442015afee502677cd28f80-0.jpg)
列编辑
可以连续一系列注释自增的数字, 在命令行模式,输入如下命令:
自增的方案来源这往篇文章:link