如何从 VIM 运行 C 程序? [英] How do I run a C program from VIM?
本文介绍了如何从 VIM 运行 C 程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有没有办法在不输入文件名的情况下从 VIM 编译和运行 C 程序?
Is there a way to compile and run a C program from VIM without typing its filename ?
推荐答案
:!gcc -o somename % &&./somename
使用 :!
时,% 将替换为当前打开的文件名.
:!gcc -o somename % && ./somename
When using :!
, % will be substituted by the name of the currently opened file.
当你的项目变大时,你也可以写一个makefile,用:make
编译当前项目,如果有错误,vim会自动跳转.
When your project becomes larger, you can also write a makefile and compile the current project with :make
, if there are any errors, vim will jump to them automatically.
这篇关于如何从 VIM 运行 C 程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文