:vimgrep続きです。
前回は、getqflistを表示するところまでやりました。
今回は、変数に格納して各パラメータを見てみます。
let a=getqflist() :echo a

1行目だけ確認。
:echo a[0]

各メンバを整理すると、
a[0].lnum: 1 a[0].bufnr: 2 a[0].col: 1 a[0].valid: 1 a[0].vcol: 0 a[0].nr: 0 a[0].type: x a[0].pattern: a[0].text: HELLO1
ん? quickfix listの中に、ファイル名は入ってないんですね。
getqflist()のヘルプを確認。
getqflist([{what}]) *getqflist()*
Returns a list with all the current quickfix errors. Each
list item is a dictionary with these entries:
bufnr number of buffer that has the file name, use
bufname() to get the name
module module name
lnum line number in the buffer (first line is 1)
col column number (first column is 1)
vcol |TRUE|: "col" is visual column
|FALSE|: "col" is byte index
nr error number
pattern search pattern used to locate the error
text description of the error
type type of the error, 'E', '1', etc.
valid |TRUE|: recognized error message
バッファ番号から、bufname()でファイル名を引けば良さそうです。
:echo bufname(2)



コメント