2010-12-09 67 views
7

我不確定在Vim的quickfix列表中的%t格式說明符。它如何影響quickfix緩衝區的行爲/顯示?Vim的quickfix列表中errorformat的錯誤類型是什麼?

我試圖找到它與下面的測試文件:

$ cat test.out 
foo    Error   1 foo.h   foobar 
bar    Error   2 foo.h   foobar 
foobar   Warning  3 foo.h   foobar 
barfoo   Warning  4 foo.h   foobar 

而下面errorformat第一:

set errorformat+=%.%#%*\\s%.%#%*\\s%l\ %f%*\\s%m 

有了這個errorformat的地方,我可以用:cgetfile test.out並跳轉到行數字爲foo.h,但以下爲errorformat

set errorformat+=%.%#%*\\s%t%.%#%*\\s%l\ %f%*\\s%m 

所有改變的是,現在我在quickfix緩衝區中的行號之後看到一些空格,例如,我看到

foo.h|1 | foobar 

代替

foo.h|1| foobar 

所以我有兩個問題(1後兩個空格):

  1. 什麼是錯我的errorformat
  2. 如果可以提取錯誤類型,應該看到什麼?

回答

5

這不是你的問題的答案,而是我自己使用的替代解決方案。 就我個人而言,我發現errorformat系統太複雜了,而是使用了一個常用的非常簡單的errorformat,這個errorformat是由一個真實函數的輸出提供的,我通過管道輸出make命令。 我用這個:「%f \%l \%c \%m」。 我在python中編寫了這些錯誤解析函數,但是任何支持的腳本語言都應該這樣做,甚至是vimL。 這是一個邏輯,這樣一個函數更容易調試,可用於vim之外,並且(至少對我而言)寫起來比製作errorformat字符串更快。

+0

這聽起來很合理。當我玩弄ctags -x -c-kinds = f 時,我偶然發現了錯誤類型,以獲取所有函數的列表到quickfix緩衝區中,以便於查看並跳轉到我正在訪問的文件中。當然,我正在嘗試的下一件事是獲得quickfix中列出的所有有趣的東西/標籤和一些小的標識符來區分宏,函數,變量等,錯誤類型看起來像一個很好的嘗試... – 2010-12-10 16:40:18

1

我在quickfix.txt中找到了以下示例,其中使用%t

Examples
The format of the file from the Amiga Aztec compiler is:
filename>linenumber:columnnumber:errortype:errornumber:errormessage

filename name of the file in which the error was detected 
linenumber line number where the error was detected 
columnnumber column number where the error was detected 
errortype type of the error, normally a single 'E' or 'W' 
errornumber number of the error (for lookup in the manual) 
errormessage description of the error  

This can be matched with this errorformat entry:
%f>%l:%c:%t:%n:%m

看來,一些編譯器都存儲在一個單一的符號E或W錯誤類型,大概是錯誤和警告。

請記住它是單個字符,因此它不會匹配「警告」或「錯誤」。
%t error type (finds a single character)

+0

我已經很多知道,所以錯誤類型是單個字母,但quickfix對這個單個字母做了什麼?它應該以某種方式顯示它? – 2010-12-10 16:37:09

7

I'm unsure about the %t format specifier in Vim's quickfix list, how does it affect the behavior/display of the quickfix buffer?

它告訴的quickfix緩衝區的錯誤類型的匹配(錯誤,警告或信息)。然後,quickfix緩衝區將在行號後面顯示該信息,並用不同的顏色突出顯示該信息。例如,這裏是一個警告和一個錯誤:

hosts.cfg|3473 error| Could not add object property 
hosts.cfg|3790 warning| Duplicate definition found for host 'mailgateway' 

在quickfix窗口中的「警告」是黃字「錯誤」的紅底白字。在我的錯誤格式中,我正在使用%t,其中E或W將出現錯誤或警告。例如:

%trror: %m in file '%f' on line %l