1

我在 Windows 机器上运行 Vim,我想将我对 pc_lint 的使用集成到 Vim 中。我已经想出了如何从 Vim 中运行 lint,但是我不知道如何将输出抓取到 Vim 中,理想情况下如何解析输出以便我可以通过错误消息跳转到正确的代码行。

有谁知道可以做到这一点的插件吗?我找不到一个。

对这个 Vim 新手有什么建议吗?

干杯,安德鲁

4

2 回答 2

3

我相信你想要这个:redir命令。

有关详细说明,请参阅此链接:http: //vim.wikia.com/wiki/Capture_ex_command_output

实际上,这里有一个更简单的方法:

:r ! command

这会将命令的结果读入当前缓冲区。

于 2011-06-17T00:27:16.883 回答
3

好的,我让它工作了。

我的 efm 设置无法正常工作。

在我的 pc_lint 配置文件中,我有以下设置:

-"format=%(%f %l %C %) %t %n: %m" 

在我的 vimrc 文件中,我有以下设置:

set efm=%f\ \ %l\ \ %c\ \ %m 

我的 vimrc 中也有以下脚本

" map f4 to run lint

map <f4> :call LintProject()<cr>

"use windows default shell

set shell=cmd.exe

function! LintProject()

    new "open a new buffer

    exec 'silent r! lint-nt c:\lint\vim\std.lnt *.c -b'

    exe "normal ggdd"  "remove blank line at the top of the file

    caddb "add content of the buffer to the quickfix window

    close "close the buffer

    copen "open quickfix window

endfunction

现在我可以像往常一样在快速修复窗口中移动,当我按下回车键时,我会被带到有错误的文件。

极好的!!!

于 2011-06-17T15:07:31.673 回答