How to display all results of a search in vim

前端 未结 3 1579
面向向阳花
面向向阳花 2021-01-13 13:33

When searching string with notepad++, new window opens and shows find results. I want to use this feature in vim. After googling I found out some suggestions:



        
3条回答
  •  猫巷女王i
    2021-01-13 14:22

    The requirement is actually easy. but to get user inputted pattern, you need a function.

    function! FindAll()
        call inputsave()
        let p = input('Enter pattern:')
        call inputrestore()
        execute 'vimgrep "'.p.'" % |copen'
    endfunction
    

    if you want to have a mapping, add this line:

    nnoremap  :call FindAll()
    

    but as I commented under your question. % may not work for unamed buffer.

提交回复
热议问题