Results 1 to 8 of 8
hi,,i am new on linux programming..i want to know how can i compile a c program on vim editor?which commands should i use?
thanks for reading.....
Enjoy an ad free experience by logging in. Not a member yet? Register.
- 10-14-2005 #1Just Joined!
- Join Date
- Sep 2005
- Posts
- 20
vim compile
hi,,i am new on linux programming..i want to know how can i compile a c program on vim editor?which commands should i use?
thanks for reading..
- 10-14-2005 #2Linux Engineer
- Join Date
- Apr 2005
- Location
- Buenos Aires, Argentina
- Posts
- 908
compile a program on vim? vim is an editor.. it has nothing to do with compiling!
serzsite.com.ar
"All the drugs in this world won\'t save you from yourself"
- 10-14-2005 #3
Well, it can be done by executing shell commands, but this is not what I recommend.
Write your program in vi, then type, in command mode, ":wq" and enter. This will save your file and exit you from vi.
Now, back on the commandline, enter:
This will use gcc to compile your program, display all errors, and name the resulting executable "foo".Code:gcc -Wall -o foo foo.c
If you get an error about "gcc: command not found", you need to install gcc. The path for this is distro-dependent.
Okie dokie?
- 10-14-2005 #4
You can run shell commands in vim, so to compile something you'd use: Esc
within the editor.Code::!gcc -Wall -o foo foo.c
- 10-14-2005 #5How would you recommend compiling something then?
Originally Posted by Cabhan
- 10-15-2005 #6
I'd recommend doing it outside vim, in the shell proper, as opposed to the within-vim option indicated by dylunio.
Ah, I see how that's ambiguous. I apologize.
And actually, now looking at it, I see that it may not be such a bad solution at all. *shrugs* I guess I just prefer to operate outside vim for running my apps.
So yeah, you can either exit to the shell proper or use dylunio's within-vim option. Bother are viable.
- 10-15-2005 #7
I know what you mean. I thought you meant not to use the shell.
But I have a similar qualm with the Emacs shell. I really don't use it much for compiling because of its rudimentary functionality ( although in Emacs' defense, the documentation doesn't claim the shell to be otherwise! ) such as lack of tab-completion.
Oh well...
- 10-16-2005 #8Linux User
- Join Date
- Jul 2004
- Location
- Poland
- Posts
- 368
Well, Vim has a nice, little feature called 'quickfix' that enables you to invoke make utility from within and provides a nice navigation over spotted errors. Type ":help quickfix" in Vim to learn more. Regards...
"I don't know what I'm running from
And I don't know where I'm running to
There's something deep and strange inside of me I see"


Reply With Quote
