1. ホーム
  2. search

[解決済み] Vimの検索でヒットしたものをリストアップするには?

2022-10-18 12:25:44

質問

ヒットしたときに、マッチしたものをリストアップしたいのですが。

/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