你怎么能列出Vim的search匹配?
我想列出比赛,当我点击:
/example 这样我就可以看到所有的比赛是在哪里。
  " put in your ~/.vimrc file " START search related configs and helps " " ignore case when searching set ignorecase " search as characters are entered, as you type in more characters, the search is refined set incsearch " highlight matches, in normal mode try typing * or even g* when cursor on string set hlsearch " yank those cheat commands, in normal mode type q: than p to paste in the opened cmdline " how-to search for a string recursively " :grep! "\<doLogErrorMsg\>" . -r " " how-to search recursively , omit log and git files " :vimgrep /srch/ `find . -type f \| grep -v .git \| grep -v .log` " :vimgrep /srch/ `find . -type f -name '*.pm' -o -name '*.pl'` " " how-to search for the "srch" from the current dir recursively in the shell " vim -c ':vimgrep /srch/ `find . -type f \| grep -v .git \| grep -v .log`' " " how-to highlight the after the search the searchable string " in normmal mode press g* when the cursor is on a matched string " how-to jump between the search matches - open the quick fix window by " :copen 22 " how-to to close the quick fix window " :ccl " F5 will find the next occurrence after vimgrep map <F5> :cp!<CR> " F6 will find the previous occurrence after vimgrep map <F6> :cn!<CR> " F8 search for word under the cursor recursively , :copen , to close -> :ccl nnoremap <F8> :grep! "\<<cword>\>" . -r<CR>:copen 33<CR> " omit a dir from all searches to perform globally set wildignore+=**/node_modules/** " use perl regexes - src: http://andrewradev.com/2011/05/08/vim-regexes/ noremap / /\v " " STOP search related configs and helps 
 :g//p 
在其更长的forms:
 :global/regular-expression/print 
你可以省略模式/正则expression式,Vim将重新使用以前的search词。
琐事: grep工具是根据这个命令序列命名的。
你也可以做一个:
 g/pattern/# 
这将打印你想要的模式和行号。
如果你想查看这个列表,并在比赛之间快速跳转,请考虑使用
 :vimgrep example % 
要么
 :grep example % 
 这将填充所有匹配的“错误列表”,以便您可以使用:copen将它们全部列出在quickfix缓冲区中,在特定行上按Enter键跳转到匹配项,或使用如下命令:cn和:cp来回走。 
有关详细解释,请参阅我对类似问题的回复
 刚学到一个新的: Location List ! 
 input:lvim foo %在当前文件中searchfoo ,并将包含foo所有匹配input到位置列表中 。 
 键入:lopen在quickfix窗口中打开位置列表,该窗口与往常一样完全可导航。 
 使用:lnext / :lnext来通过列表(使用tpope / unimpaired映射获得最佳体验) 
另一种可能是使用包含文件search命令。
 [I 
这将列出光标下所有出现的单词。 它可能比你需要更多,因为它也会search当前文件中包含的任何文件。
但是这个命令的好处在于search结果显示除了每个匹配的行号以外,还显示匹配次数的计数。
 :help include-search 
看到很多变种。
关于的一个笔记
 :g//p 
这可以进一步减less
 :g// 
因为像其他人所说的那样,p(rint)是默认行为。
 使用:set hlsearch将突出显示黄色的所有匹配项,以便您轻松扫描文件进行匹配。 这可能不是你想要的,但search之后:g // p会给你列出的匹配项 
详细说明这个…而不是
 /example :g//p 
你也可以直接写
 :g/example/p 
或者,因为p(rint)是:g(lobal)命令的默认动作,所以可以缩短为
 :g/example 
而不是p(rint),其他的行为是可能的,例如d(elete)。 请参阅:help:global
 g/pattern 
 如果您有:set number ,则上述命令也会显示行号。 
 如果你还没有:set number ,那么 
 g/pattern/# 
将显示行号。
 你可以得到一个很好的quickfix窗口,其中匹配forms是你当前的search模式 
 :vim // % :copen 
 超级方便,如果你以前使用/pattern制作复杂的search/pattern 
编辑 :刚才发现这也适用于所有打开的缓冲区
 :bufdo vimgrepadd // % :copen 
Ctrl-f列出所有search结果:
 nmap <Cf> :vimgrep /<Cr>//g %<CR> \| !:copen <Enter>