我不确定Vim的快速修复列表中的%t格式说明符。它如何影响quickfix缓冲区的行为/显示?
我试图用以下测试文件找到它:
$ 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缓冲区中看到了行号后面的一些空格,例如,我看到了(1后面的两个空格)
foo.h|1 | foobar而不是
foo.h|1| foobar所以我有两个问题:
我的errorformat
发布于 2011-01-26 22:00:29
我不确定Vim的quickfix列表中的%t格式说明符,它如何影响quickfix缓冲区的行为/显示?
它将告诉quickfix缓冲区匹配的错误类型(错误、警告或信息)。然后,quickfix缓冲区将在行号之后显示该信息,并以不同的颜色突出显示它。例如,这里有一个警告和一个错误:
hosts.cfg|3473 error| Could not add object property
hosts.cfg|3790 warning| Duplicate definition found for host 'mailgateway'在quickfix窗口中,“警告”一词为黄色,"error“则为红色的白色。在我的错误格式中,我使用的是%t,其中E或W将出现错误或警告。例如:
%trror: %m in file '%f' on line %l发布于 2010-12-10 02:20:26
这不是你问题的真正答案,而是我自己使用的另一种解决方案。就我个人而言,我发现错误格式系统太复杂了,而是使用了一个普通的非常简单的错误格式,它是由一个实际函数的输出提供的,我通过管道传输make命令的输出。我使用的是:"%f\ l\\c\\m“。我用python编写了这些错误解析函数,但是任何受支持的脚本语言都应该这样做,甚至是vimL。这样做的逻辑是这样一个函数比创建错误格式字符串更容易调试,可以在vim之外使用,而且(至少对我来说)编写起来更快。
发布于 2010-12-10 08:52:50
我在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)
https://stackoverflow.com/questions/4403824
复制相似问题