Is there a way to compile and run a C program from VIM without typing its filename ?
+11
A:
:!gcc -o somename % && ./somename
When using :!
, % will be subsituted by the name of the currently opened file.
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.
tstenner
2010-04-13 08:06:15
+1 for pointing out that % is substituted by the filename.
René Nyffenegger
2010-04-13 08:11:27
I like you answer. I want to make it final. Please guide.
Coder
2010-04-13 09:12:08
I need 15 votes to make it final :(
Coder
2010-04-13 09:13:24
@Coder: No, you can accept the answer. Just click the check. You don't need any amount of votes for that.
rampion
2010-04-14 21:57:29
+2
A:
use the following mapping code in your .vimrc file. for compile and run a c programming file.
map : !gcc % && ./a.out
F8 key for run the mapping.
"%" is taken the current file name.
ungalnanban
2010-04-16 04:31:53