cscopeを使用してvimのシンボルの定義に移動すると、多くの候補が結果ウィンドウに表示される場合があります。ウィンドウ内で検索を実行して、必要なものをすばやく見つけたいと思います。ただし、検索機能(/)は結果ウィンドウでは機能しないようです。使用できるキーは、j、k、gg、Gなどです。
cscopeの結果ウィンドウで検索する方法はありますか?または、そのような状況でより効率的に作業する方法について、誰かが経験を共有できますか。
ありがとう。
以下を使用できます。
" Filter the quickfix list
function! FilterQFList(type, action, pattern)
" get current quickfix list
let s:curList = getqflist()
let s:newList = []
for item in s:curList
if a:type == 0 " filter on file names
let s:cmpPat = bufname(item.bufnr)
elseif a:type == 1 " filter by line content
let s:cmpPat = item.text . item.pattern
endif
if item.valid
if a:action < 0
" Keep only nonmatching lines
if s:cmpPat !~ a:pattern
let s:newList += [item]
endif
else
" Keep only matching lines
if s:cmpPat =~ a:pattern
let s:newList += [item]
endif
endif
endif
endfor
call setqflist(s:newList)
endfunction
次に、4 つのマッピングを定義します (ø を自分に合ったものに置き換えます。私の場合は ð で始まりますが、これはキーボードでは使用できない可能性があると思います)。それぞれにマップされます。
nnoremap ø :call FilterQFList(0, -1, inputdialog('Remove file names matching:', ''))<CR>
nnoremap ø :call FilterQFList(0, 1, inputdialog('Keep only file names matching:', ''))<CR>
nnoremap ø :call FilterQFList(1, -1, inputdialog('Remove all lines matching:', ''))<CR>
nnoremap ø :call FilterQFList(1, 1, inputdialog('Keep only lines matching:', ''))<CR>
このようにして、任意のパターンでクイックフィックス リストをフィルタリングできます (vim reg.exps の力を利用できます)。:cnewer
とを使用し:colder
て、前のクイックフィックス リストをジャンプします。