Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How compile C in vi and run it?

Tags:

vi

Environment: MacOS, gcc, Vim7.2

I know I can do it in Emacs. Compile code and run it. I am wondering how can I do it in vi? I don't want to switch from vi to terminal a lot. thanks! :)

like image 452
Josh Morrison Avatar asked Apr 02 '11 05:04

Josh Morrison


1 Answers

vim does have a inbuilt :make command, but it has to be associated with the compiler. Some examples are:

GNU gcc compiler:

set makeprg=gcc\ -o\ %<\ %

Intel Fortran compiler:

set makeprg=ifort\ %\ -o\ %<
  • \ represents blank space
  • % input file
  • %< output file
like image 130
jadelord Avatar answered Oct 12 '22 05:10

jadelord