在 Vim 中显示匹配数

编程入门 行业动态 更新时间:2024-10-06 22:28:44
本文介绍了在 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:

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 中显示匹配数

本文发布于:2023-10-19 01:44:35,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1506025.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:Vim

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!