当您进行搜索时,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:
vim.wikia/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 中显示匹配数
发布评论