在 Vim 中显示匹配数 [英] Show Count of Matches in Vim

查看:73
本文介绍了在 Vim 中显示匹配数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当您进行搜索时,Google Chrome 中有一个不错的功能.它会告诉您与您正在搜索的关键字匹配的数量.但是,在 Vim 中我没有看到这样的功能.有些人建议使用 %s/pattern//gn 或类似的:

There is a nice feature in Google Chrome when you do a search. It tells you the number of matches there is for the keyword you are searching for. However, in Vim I don't see such a feature. Some people suggested using %s/pattern//gn or similar:

http://vim.wikia.com/wiki/Count_number_of_matches_of_a_pattern
无法统计 Vim 中的匹配数

但这真的很长!!我正在查找按*"、%"或使用/"和?"进行任何搜索时的计数.

But that is quite long really!! I am looking for the count when a press the '*', '%', or do any search using '/' and '?'.

有什么想法吗?

推荐答案

Modern Vim

Vim 8.1.1270 开始,有/a> 在 core 中显示当前匹配位置.NeoVim 默认启用此功能,但标准 Vim 不启用.

Modern Vim

Starting with Vim 8.1.1270, there's a new feature in core to show the current match position. NeoVim enables this functionality by default, but standard Vim does not.

要在标准 Vim 中启用它,请运行:

To enable it in standard Vim, run:

:set shortmess-=S

最初在Ben's answer,并在此处添加以供查看.

Originally mentioned below in Ben's answer, and added here for visibility.

在 Vim 7.4+ 中,可以使用 IndexedSearch 插件.

In Vim 7.4+, the IndexedSearch plugin can be used.

在 GitHub 上查看 henrik/vim-indexed-search 以确保您获得最新版本.

Check henrik/vim-indexed-search on GitHub to ensure you get the latest version.

这篇关于在 Vim 中显示匹配数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆