【问题标题】:How do I configure Vim to capture PC_Lint's output如何配置 Vim 以捕获 PC_Lint 的输出
【发布时间】:2011-06-17 00:23:11
【问题描述】:

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

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

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

干杯, 安德鲁

【问题讨论】:

    标签: vim lint


    【解决方案1】:

    我相信你想要:redir 命令。

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

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

    :r ! command

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

    【讨论】:

    • 感谢您让我参与其中。我将输出放在缓冲区中,无论如何让 vim 智能地解析错误,以便我可以跳转到导致错误的相应代码行。
    • 你想要的是 vim 的 quickfix。这是链接。我用 php 的 lint 进行了这个设置,以完全按照您的意思进行操作。 vimdoc.sourceforge.net/htmldoc/quickfix.html
    【解决方案2】:

    好的,我让它工作了。

    我的 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
    

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

    太棒了!!!

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2012-01-27
      • 2022-01-07
      • 2018-11-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-09-29
      相关资源
      最近更新 更多