Chapter 3 Searching
Simple Searches
I remember i used to use a stupid ':' before '/' , now I know that only '/' is enough!
find a string: /string<ENTER>
*[]^%//?~$ have special meaning, so if you want to use them in a search you must put a backslash / in front of them
find a . : //.
to find the next matching, you can use either /<Enter> or n 3/ and 3n are also correct
Make full use of search history
input a /, then use <Up> key, u will find search history
Searching options
Highlighting
:set hlsearch
:set nohlsearch
只是把当前搜到的结果去除Highlighting的方法是 :nohlsearch
Incremental searches
:set incsearch
:set noincsearch
Searching Backward
use ? instead of /
? and n to find next matching backward 3? and 3n are also correct
Changing Direction
reverse the direction: N (注意一个小点,就在第一次会转向,然后就和n一样了;就是说第一次使用N的时候会转向)
always backward: ?
always forward: /
always the same direction: n
Basic Regular Expressions: extremely powerful and compact way to specify a search pattern
start of line: ^
end of line: $
a single charater: .
x: any literal charater x
/charater: turns off the special meaning of many charaters
Example:
/^the
/the$
/^the$: means only 'the' appears in the line, spaces cannot appear either in front of 'the' or after 'the'
/^$: search for empty line
生单词一枚coincidence [koˈɪnsɪdəns] n. 1. (令人吃惊的)巧合,巧事2. (意见等的)相同, 符合, 一致3. 同时存在;并存
Example: It is no coincidence that this is also the command to move to the beginning of the line.
我觉得这句话的意思就是说:并不是巧合。。。意味着是必然