Link to home
Start Free TrialLog in
Avatar of totsubo
totsubo

asked on

Using vi to write programs?

I'm teaching myself vi. I mainly want to use it to write C/C++ programs

I'd like to know how to get it to do a few things automatically for me such as:

-autoindent
-auto-generate closing brace on opening brace input
-auto generate */ on /* input

Is this possible?

Thanks!
Avatar of jlevie
jlevie

Probably not with most of the simple vi implementations. There might be one of the enhanced vi clones vim, elvis, etc that has a Language Sensitive Mode, but the best editor w/respect to programming languages (in my opinion) is either Emacs or Xemacs.
the first one  is absolutely possible

auto indent is done by giving
"set ai" in the .exrc file

the second one is done by givng set showmatch .This means it wont automatically generate closing bracesbut it will check for the matching(corresponding)opening braces every time when a brace is closed.

i'm sorry about the third one


ASKER CERTIFIED SOLUTION
Avatar of hongjun
hongjun
Flag of Singapore image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
There is actually no way for auto inserting */ and } whenever you enter an opening tag for the corresponding tag.

However, autoindent is possible. Go to command mode by entering Esc key and then enter the below command.

:set autoindent

Note: vi editor is case-sensitive.
Hopes it helps.

hongjun