2014-07-24 18 views
0

我使用/pattern匹配當前文件中的模式,有沒有一種方法可以顯示我之前搜索命令的回車後有很多很多匹配項?然後我會感覺到有多少導航可以完成所有的導航。獲取在vim中給定模式匹配的次數

回答

1

您可以定義一個簡單的映射,打印匹配的數量:

:nnoremap <A-n> :%s///gn<CR> 
41 matches on 17 lines 

SearchPosition plugin爲此提供了一個更復雜的變體:

1 match after cursor in this line, 8 following, 2 in previous lines; 
total 10 within 11,42 for /\<SearchPosition\>/ 

另外還有IndexedSearch plugin,它集成了報告與n/N命令。

0

作爲替代/pattern,你可以使用:

:vim /pattern % | cw 

在quickfix窗口打開匹配的列表。

您還可以使用:

:il[ist] /pattern/ 

,並從列表中選擇有:

:{line number}