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大家讲道理2017-05-16 16:43:13
Second question:
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
并插入 // 0
,按 Esc
to return to normal mode0
:I
to change it to an increasing numerical sequenceset ve=
把虚拟编辑选项复原(我推荐使用非默认值 block
, so you don’t have to switch frequently)PS: Usually it cannot be represented by an enumerated integer, right?
阿神2017-05-16 16:43:13
The first question, use regular expressions when searching:
Second question, just record a macro:
// 1
at the end
qq^f y$j$p^A
Explain:
qq
: 录制宏到寄存器 q
^
: Go to the beginning of the tripf
: (注意 f
followed by a space), go to the first space y$
: Copy to end of linej$p
: Paste at the end of the next line^A
: (This is Ctrl-A) +1某草草2017-05-16 16:43:13
Second question
Use 列编辑
to make a series of comments
To auto-increment the number, in command line mode, enter the following command:
:let i=0|g/0/s//\=i/|let i=i+1
The source of the self-increasing solution is this article: link