Monday, July 17, 2006

A small tips for C/C++ programming with Vi Editor

I am using vi editor to write my C program. I found some good feature with Vi editor which will help programmer to write C program clean and readble. Also reduce time to debug the C/C++ source file.

Start C style Indent in Vi Editor
:set cindent

ctags
just make a command " ctags *" on your source directory. Ctags command will create one file called tags which contains defined
macros defined by #define
enumerated values
function definitions, prototypes, and declarations
class, enum, struct, and union names
namespaces
typedefs
variables (definitions and declarations)
class, struct, and union members

Now open vi editor with source file name and put
: tag [i.e if i have a function fun() then it sould be :tag fun or just pressed ,it will list down all the tag name and hit enter . It willl jump where fun() has been defined. Just put ctrl+T to come back.

Syntax highlight:

:syntax on

Auto make

If you prepare makefile for your program then vi will allow you to run your program within vi. Just type
:make
[for more details :h make]

No comments: