Common search techniques in the vim editor

Step 1: Enter vim editor

vim /etc/ssh/ssh_config

 

Step 2: Search method

Method 1: Quick search (exact string match, case sensitive)

Format: / + keyword or ? + keywords

/Port     #按回车键搜索   从上到下查找
?Port     #按回车键搜索   从下到上查找

 

Advantages: quickly locate the keyword

After pressing Enter, press  to search for the next matching result that appears, and press uppercase  to search for the next matching result that appears in reverse.

Method 2: Whole word search

Format: / + \< + keyword + \>

/\<Iden\>

 After pressing Enter, press    to search forward or  backward.

Step 3: Search History

Format: / + up and down arrow keys   

press enter after selection

Step 4: Case Sensitive

By default, searches are case sensitive. Searching for "YES" will not match "yes".

:set ignorecaseTo ignore case, enter or on the Vim command line :set ic. You can also add a default option to your ~/.vimrcfile to ignore case.

To change back to case-sensitive, enter :set noignorecaseor :set noic.

Another way to force case to be ignored is to add it after the search pattern \c. For example, /Linux\ccase sensitivity will be ignored when searching. Adding uppercase after the search style \Cwill force case sensitivity.

Guess you like

Origin blog.csdn.net/weixin_42517271/article/details/127993888