[英]Vim errorformat <Nul> characters
The errors produced by ghc-mod
are on a single line, where each line may potentially contain the <Nul>
character, rendered as \\@
by vim. ghc-mod
产生的错误在一行上,其中每行可能包含<Nul>
字符,由vim表示为\\@
。 I'd like to parse this for quickfix, but can't see how this might work with errorformat
: the <Nul>
character seems to truncate %m
as if it were a new line, but using multiline syntax doesn't seem to be working to catch this case. 我想将其解析为quickfix,但无法看到它如何与errorformat
: <Nul>
字符似乎将%m
截断,就好像它是换行符一样,但是使用多行语法似乎并不可行。努力抓住这种情况。
Is there a way to make errorformat
parse <Nul>
? 有没有办法使errorformat
解析<Nul>
?
A program that carelessly outputs null characters in a Unix environment is just begging for trouble. 一个在Unix环境中粗心输出空字符的程序只是乞求麻烦。
No, for all I see Vim cannot handle null characters when parsing output with 'errorformat'
. 不,就我所知,在使用'errorformat'
解析输出时,Vim无法处理空字符。 (It is possible to add NULs to the errorformat string by prefixing them with CTRL-V
, ie ^V^@
, but this is useless.) (可以通过将NUL加上CTRL-V
前缀(即^V^@
将NUL添加到错误格式字符串,但这是没有用的。)
The work-around for output that isn't suited for Vim's errorformat is to add a filter to the 'makeprg'
program and then use :make
to populate the quickfix list: 不适合Vim 'makeprg'
输出的解决方法是在'makeprg'
程序中添加一个过滤器,然后使用:make
来填充'makeprg'
列表:
:set makeprg=ghc-mod\ lint\ %\ \\\|\ tr\ -d\ '\\0'
:make
This hint can be found at the very end of :h error-file-format
. 该提示可以在:h error-file-format
。
A much better solution is to simply not bother and use the popular ghcmod plugin that does this and much more. 更好的解决方案是简单地避免打扰并使用流行的ghcmod插件来执行此操作以及执行更多操作。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.