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

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.

主站蜘蛛池模板: 绥中县| 桐乡市| 凤山县| 云浮市| 沅陵县| 邓州市| 建湖县| 巫山县| 迁西县| 舒兰市| 炎陵县| 贺州市| 九龙县| 德昌县| 松潘县| 贵州省| 库尔勒市| 抚宁县| 台东市| 汾西县| 中西区| 瑞丽市| 辰溪县| 桐乡市| 镇坪县| 大新县| 南召县| 泰宁县| 九江县| 于田县| 西平县| 沭阳县| 平定县| 西峡县| 承德县| 正定县| 绥阳县| 阿城市| 隆昌县| 永和县| 如东县|