在vim/gvim中静默执行 [英] Silent make execution in vim/gvim

查看:71
本文介绍了在vim/gvim中静默执行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用gvim启动make并为我的代码进行构建.由于构建过程需要一些时间,因此我希望它能够以静默方式执行,然后最终向我显示错误/构建日志.

I want to use gvim to launch make and do the build for my code. Since the build process takes some time i want it to be silently executed and then in the end errors/build log be showed to me.

我已将此添加到我的.vimrc

i have added this to my .vimrc

:command -nargs=* Make silent make <args>  | cwindow 10
map <c-b> <c-o>:Make<cr>

因此,当我按Ctrl-b时,它将开始构建.但是,当我这样做时,我的gvim挂起了,我有时无法做任何事情.有没有一种方法可以完成我想做的事情.

So when i press Ctrl-b it starts building. But when i do that my gvim hangs and i cant do anything for sometime. Is there a way to accomplish what i am trying to do.

由于我在make末尾使用了 cwindow 10 ,因此它将启动quickfix窗口.除此之外,我还想查看构建日志.我能以某种方式做到这一点

Since i am using cwindow 10 at the end of make , it launches the quickfix window. In addition to that i also want to see the build log. Can i somehow do that

推荐答案

正如我在类似问题中所说:看我的

As I said in similar questions: Have a look at my AsyncCommand plugin. Add the script to your .vim/plugin and you can build with :AsyncMake or :AsyncMake target. Errors will be opened in your quickfix once the make completes.

对于日志文件,您可以扩展AsyncMake来同时打开构建日志.在安装asynccommand.vim之后,将其添加到您的vimrc中:

For the log file, you could extend AsyncMake to also open the build log. Add this to your vimrc after you've installed asynccommand.vim:

function! AsyncMakeWithLog(target)
    let make_cmd = &makeprg ." ". a:target
    let vim_func = "OnCompleteLoadErrorAndLog"
    call AsyncCommand(make_cmd, vim_func)
endfunction
" Load the output as an error file and load the full build log
function! OnCompleteLoadErrorAndLog(temp_file_name)
    call OnCompleteLoadErrorFile(a:temp_file_name)
    call OnCompleteLoadFile(a:temp_file_name)
endfunction

但是,日志文件和错误窗口将包含很多相同的文本,因此您不一定总是需要两者.如果您的构建工具已经将其构建日志写入磁盘,那么我建议您让构建输出中包含构建日志的完整路径.这样,您可以在错误窗口中的路径上键入 gf ,以在需要时跳转到构建日志.

However, the log file and the error window will have a lot of the same text, so you don't always need both. If your build tool already writes its build log to disk, then I'd suggest you have the build output include the full path to the build log. That way you can type gf on the path in the error window to jump to the build log when necessary.

这篇关于在vim/gvim中静默执行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆