The Linux (or unix) command vi is a powerful command line editor tool which has a long history with unix and the maintenance of C code (as just one example of its uses).
So much so, as far as C coding goes, that the creators of vi clearly thought you may “set up shop” in the vi world, because, if you have a makefile, like our simple one for today’s tutorial, you can use vi‘s :make command to compile your C or C++ code while in vi … for those thinking that they never “make” syntax errors in C … hope you know where all the Kryptonite supplies are?
You’ll notice that you can run that compiled code (if successful) and still not leave vi via :!./Hello (where the ! is taking you to the parent shell).
There are other text editors for command line Linux (or unix), some being pico and emacs, and there is a bigger version of vi called vim.
The thing about a lot of command line text editors is that they look unfriendly (it’s less unfriendly if you know {ESC}: gets you to the : prompt from the screen view … second green arrow in tutorial picture included this), and that can be true, and this has lead me to do more work with the GUI TextWrangler (when on a Mac) if there is going to be much cutting, copying and pasting, but you should know that vi has functionality to do with buffers, and some years back, there were maybe 6 or 7 days I’d have preferred to do copying and pasting between buffers using vi … you’re right … I’ll “take a Bex” and lie down now.
Here is a link to some downloadable C code you could call Hello.c and its associated makefile designed for Linux command line compilation via gcc (and here is a good tutorial regarding makefiles for gcc compiler … thanks).
If this was interesting you may be interested in this too.
5 Responses to Linux vi C make Primer Tutorial