hongjun
asked on
Vim
I am using Solaris.
Does vi or vim has got auto-indent option just like emacs?
I know it is possible to use a .vimrc file but then it will only help in indenting while you type. For example if I were to remove a if-statement, then perhaps I will end up re-indentiing manually each line. Very troublesome process.
hongjun
Does vi or vim has got auto-indent option just like emacs?
I know it is possible to use a .vimrc file but then it will only help in indenting while you type. For example if I were to remove a if-statement, then perhaps I will end up re-indentiing manually each line. Very troublesome process.
hongjun
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
found this rather good reference
http://vim.sourceforge.net/htmldoc/quickref.html
http://vim.sourceforge.net/htmldoc/quickref.html
'%' searches for a matching opposite character, so you can auto-indent over [], {}, or (). If you are indenting, say,
Pascal, you could use ">/end" followed by a carriage return, assuming Pascal uses "end" like Algol did. Vim might
be programmable so that it could search for other pairs of characters, but I have never attempted to do so. If you
know you need to indent ten lines, you could use ">10j".
Pascal, you could use ">/end" followed by a carriage return, assuming Pascal uses "end" like Algol did. Vim might
be programmable so that it could search for other pairs of characters, but I have never attempted to do so. If you
know you need to indent ten lines, you could use ">10j".
Though this may not be what you are looking for ,
there is a program "indent" which can indent your programs
http://www.gnu.org/software/indent/indent.html
there is a program "indent" which can indent your programs
http://www.gnu.org/software/indent/indent.html
ASKER
I am posting this question because I have got a Unix shell practical exam this coming Friday and new accounts will be given to all students and so will result in me not having a desired .vimrc file. But then guess I will have to make code out a .vimrc myself before I start. And because of that, definitely I am not allowed to install any new programs like the "indent" program given above.
hongjun
hongjun
ASKER
I will leave this question open a while before I finalized it.
ASKER
Hi to all.
There's another quite ok program named "cb".
$> cb yourprogram.c
Will display the formatted program..
Then we can always redirect it to a file..
Cheers
hongjun
There's another quite ok program named "cb".
$> cb yourprogram.c
Will display the formatted program..
Then we can always redirect it to a file..
Cheers
hongjun
ASKER