最近的學習工作中, 查看log文件需求特別多,
於是我對vim的搜索功能提出了新的要求.
比如:
將搜索結果單獨列在一個窗口中, 雙擊該窗口的一項是, 支持到源文件的跳轉.
可以將搜索無關項摺疊起來, 需要的時候再打開.
可以很方便的將搜索結果保存起來(到新窗口或者文件, 方便的意思指的當然是command)
如果大家也有同樣的需求, 參考如下鏈接:
這個鏈接中的See also也非常實用, see also內容如下:
See also
- Redirect g search output to redirect g// output to a new window or a file
- Filter buffer on a search result to create a scratch buffer with matching lines
- Find in files within Vim for a clickable list of search hits
- Folding with Regular Expression to fold away non-matching lines
目前我最喜歡的命令有下面幾個:
■ 使用vimgrep搜索, 雙擊搜索結果可跳轉, 並支持在多文件中搜索.
To view a window of search results, see Find in files within Vim. You can use % for the file path to search only the current file, for example:
:w
:vimgrep /pattern/ %
:copen
■ 還有, 通過Redirect g search output這個鏈接中介紹的F3命令,
只是我使用下面的命令, 將搜索結果重定向到一個新的tab, 而不是一個新的window
■ 另外還有Folding with Regular Expression之中介紹的 \z 命令, 將不匹配的搜索結果摺疊起來(在當前的window中)