官术网_书友最值得收藏!

Searching with / and ?

Most times one of the fastest ways to navigate somewhere is to search for a particular string. Vim allows you to search for a match by typing in / (which puts you in command-line mode) followed by a search string. Once you hit Enter, your cursor will move to the first match.

Cycling through the matches in the same buffer can be done by pressing n to go to the next match and N to the previous match.

A useful option for searching is set hlsearch (consider setting it in your .vimrc file), since it highlights every match on the screen. For example, this is how running /kind in animal_farm.py looks with hlsearch enabled:

You can clear the highlights by executing :noh.

Another nifty trick is using set incsearch . This will make Vim dynamically  move you to the first match as soon as you type.

In case you want to search backwards, replace / with ?. This will also affect the way n and N will behave, showing a next backward match, and a previous backward match respectively.

主站蜘蛛池模板: 建瓯市| 莫力| 临洮县| 秦皇岛市| 襄垣县| 英德市| 洪洞县| 攀枝花市| 辽源市| 柳江县| 乌鲁木齐市| 唐山市| 东兰县| 蒲江县| 山东| 镇江市| 邹城市| 盐池县| 汾阳市| 博客| 五原县| 汽车| 简阳市| 娱乐| 乐业县| 察隅县| 商洛市| 潼关县| 象山县| 无锡市| 鄂尔多斯市| 阿克| 玛多县| 建水县| 英山县| 集安市| 南宁市| 龙井市| 英吉沙县| 宜都市| 乐安县|