如何列出 Vim 搜索的匹配项? [英] How can you list the matches of Vim's search?
本文介绍了如何列出 Vim 搜索的匹配项?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想列出匹配项,当我点击时:
I would like to list the matches, when I hit:
/example
这样我就能同时看到所有匹配项的位置.
so that I see where all matches are at once.
推荐答案
" 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
这篇关于如何列出 Vim 搜索的匹配项?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文