How to display all results of a search in vim

前端 未结 3 1580
面向向阳花
面向向阳花 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条回答
  •  一个人的身影
    2021-01-13 14:07

    I suggest lvimgrep (so you can use quickfix for :make)

    :nnoremap  :lvimgrep /\M\<\m\>/ **/*.[ch]pp **/Makefile | lopen
    

    Also, if you just wanted to find in the current file:

    :g//
    

    will invoke 'print' (default command) on each matching line.

    :v//               " non-matching lines
    :g//-1             " lines preceding the matching line
    :g//-1,+1          " lines around the matching line
    

    etc.

    :global is far more useful:

     :g/foo/ join       " join all lines containing foo
    

    etc.

提交回复
热议问题