Hide all (not)matching lines in Vim

后端 未结 8 648
盖世英雄少女心
盖世英雄少女心 2021-01-30 01:35

Is it possible to show/hide all matching lines in vi or Vim? Not highlight but just show only those lines.

For example I have a text with word the word ERROR

相关标签:
8条回答
  • 2021-01-30 02:08

    Some hackish dirty way to do this:

    :w (save)
    ggdG (deletes everything)
    :.!grep something % (replace current line with grep output)
    
    0 讨论(0)
  • 2021-01-30 02:09

    The best way to do this is->

    :vimgrep /something/g % | copen
    

    This will open the list of matches for your keyword and also will show only the matched lines in quickfix window.

    Replace % with path to file if not considering the current file.

    0 讨论(0)
提交回复
热议问题