简体   繁体   English

如何正确设置Vim的makeprg(Windows)

[英]How to correctly set Vim's makeprg (Windows)

In Linux, I've used this au FileType c set makeprg=gcc\\ -o\\ %< in my .vimrc to set my default compiler for .c files, and this: nmap <F5> :<CU>silent make %<CR>:redraw!<CR>:!./%<<CR> to bind F5 key to make things faster. 在Linux中,我已在.vimrc中使用此au FileType c set makeprg=gcc\\ -o\\ %<为我的.c文件设置默认编译器,并且: nmap <F5> :<CU>silent make %<CR>:redraw!<CR>:!./%<<CR>绑定F5键以使操作更快。

How should I do this on Windows? 我该如何在Windows上执行此操作? I've tried with au FileType c set makeprg="cmd /c C:\\tcc\\tcc.exe -o %<" and some few other samples, but none have worked. 我尝试使用au FileType c set makeprg="cmd /c C:\\tcc\\tcc.exe -o %<"和其他一些示例,但是没有一个起作用。

In brief: I want to hit F5 to compile&run program in cmd or cmd with errors that compiler gave. 简而言之:我想按F5键,以编译器给出的错误在cmd或cmd中编译和运行程序。

I'd appreciate any hints how to get this thing work on Windows. 我会很感激如何在Windows上使此东西工作的任何提示。 Thanks. 谢谢。

There is no need to include cmd.exe on 'makeprg' . 无需在'makeprg'上包含cmd.exe。 The line you use in Linux should work fine if gcc is in your path. 如果gcc在您的路径中,则您在Linux中使用的行应该可以正常工作。

Another approach could be using Single Compile plugin to simplify the mapping to F5 . 另一种方法是使用Single Compile插件来简化到F5的映射。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM