我在Windows机器上运行Vim,我想将我对pc_lint的使用集成到Vim中。我已经弄清楚如何从Vim中运行lint,但是我不知道如何将输出抓取到Vim中,理想情况下如何解析输出以便我可以通过错误消息跳转到正确的代码行。
是否有人知道会执行此操作的插件?我找不到一个。
对这个Vim新手有什么建议吗?
干杯, 安德鲁
答案 0 :(得分:3)
我相信你想要:redir
命令。
有关详细说明,请参阅此链接:http://vim.wikia.com/wiki/Capture_ex_command_output
实际上,这是一种更简单的方法:
:r ! command
这会将命令的结果读入当前缓冲区。
答案 1 :(得分: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
现在我可以像往常一样移动quickfix窗口,当我按下Enter时,我将被带到错误的文件中。
奇!!!