Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
694 views
in Technique[技术] by (71.8m points)

search - Show Count of Matches in Vim

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
Unable to count the number of matches in Vim

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

Any idea?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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.

To enable it in standard Vim, run:

:set shortmess-=S

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

Older Versions

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

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...