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

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.

主站蜘蛛池模板: 兰州市| 贵定县| 建水县| 南江县| 浦东新区| 蕲春县| 台湾省| 读书| 安西县| 宁远县| 利辛县| 塔城市| 山东省| 互助| 新余市| 民丰县| 博罗县| 扶绥县| 根河市| 砚山县| 抚宁县| 方山县| 泸溪县| 芮城县| 奉新县| 沙坪坝区| 南京市| 周宁县| 仁化县| 呈贡县| 鸡泽县| 丰镇市| 偃师市| 深圳市| 濮阳市| 漠河县| 句容市| 杨浦区| 盱眙县| 乾安县| 涟源市|