[comp.editors] Aligning columns in vi

carl@mugwump.EBay.Sun.COM (Carl Johnson - Sun EHQ - MIS) (02/07/91)

Greetings,
	I dont think this got out the first time, my apologies if you've
	seen this already.

	In vi what I want to do is align certain characters into the same 
	column.  For instance :-
		/*codecodecodecodecode */
		/*codecodecodecodecodecodecodecodecodecodecodecodeco */
		/*codecodecodecodecodecodecodecodecodecode */
	some command like :1,$s/\/\*/>>\/\*/  ??
	would end up aligned so :-
		/*codecodecodecodecode				     */
		/*codecodecodecodecodecodecodecodecodecodecodecodeco */
		/*codecodecodecodecodecodecodecodecodecode           */

Cheers,
Carl.

carl@mugwump.EBay.Sun.COM (Carl Johnson - Sun EHQ - MIS) (02/07/91)

Greetings,
	>>carl@mugwump.male.ebay.sun.com.
	I dont know where it got this address from but it aint mine.  
	If you want to reply via mail the address is carl.johnson@uk.sun.com.
Cheers,
Carl.

abed@saturn.wustl.edu (Abed M. Hammoud) (02/07/91)

In article <4869@male.EBay.Sun.COM> carl@mugwump.EBay.Sun.COM (Carl Johnson - Sun EHQ - MIS) writes:
>Greetings,
>	>>carl@mugwump.male.ebay.sun.com.
>	I dont know where it got this address from but it aint mine.  
>	If you want to reply via mail the address is carl.johnson@uk.sun.com.
>Cheers,
>Carl.

	Could you please post a summery when you figure out the 
	solution.

	thanks


	--------------------------------------------------------------
	| Abed  M. Hammoud			abed@saturn.wustl.edu|
	| Washington University.	        office:(314)726-7547 |
	| Electronic Systems & Signals Research Laboratory.          |
	| Dept. of Electrical/Biomedical Engineering.		     |
	| St.Louis Mo U.S.A                                          |
	-------------------------------------------------------------- 

wyle@iiic.ethz.ch (Mitchell Wyle) (02/09/91)

In article <4868@male.EBay.Sun.COM> The manager of information systems
for Sun Microsystems' Eastern Headquarters, Carl Johnson, with e-mail
address:  carl@mugwump.EBay.Sun.COM tells us:

>	In vi what I want to do is align certain characters into the same 
>	column.  For instance :-
>		/*codecodecodecodecode */
>		/*codecodecodecodecodecodecodecodecodecodecodecodeco */
>		/*codecodecodecodecodecodecodecodecodecode */
>	some command like :1,$s/\/\*/>>\/\*/  ??
>	would end up aligned so :-
>		/*codecodecodecodecode				     */
>		/*codecodecodecodecodecodecodecodecodecodecodecodeco */
>		/*codecodecodecodecodecodecodecodecodecode           */
>

Use indent(1), Carl.  

Indent does it better than vi macros.  

Set up a file ~/.indentpro and send all your coders' code through
indent.  Read your MAN PAGES for the program cb (C beautifier).  It
tells us to use indent.  

When my students deliver code formatted in a style I don't like, I use indent.

When I write block comments, I usually do something like:

/*

comments lots of code or comments

*/


But then again, "De gustebus non est disputandem."

javey@hybrid.UUCP (shahram javey) (02/12/91)

In article <24231@neptune.inf.ethz.ch> wyle@iiic.ethz.ch (Mitchell Wyle) writes:
>In article <4868@male.EBay.Sun.COM> The manager of information systems
>for Sun Microsystems' Eastern Headquarters, Carl Johnson, with e-mail
>address:  carl@mugwump.EBay.Sun.COM tells us:
>
>>	In vi what I want to do is align certain characters into the same 
>>	column.  For instance :-
>>		/*codecodecodecodecode */
>>		/*codecodecodecodecodecodecodecodecodecodecodecodeco */
>>		/*codecodecodecodecodecodecodecodecodecode */
>>	some command like :1,$s/\/\*/>>\/\*/  ??
>>	would end up aligned so :-
>>		/*codecodecodecodecode				     */
>>		/*codecodecodecodecodecodecodecodecodecodecodecodeco */
>>		/*codecodecodecodecodecodecodecodecodecode           */
>>
I cannot get the above to work. What is the magic component? How can
replacing /* by /*>> align comments? I hope someone explains the above.
>
>Use indent(1), Carl.  
>
>Indent does it better than vi macros.  
>
I don't have access to indent. I use vi on my DOS machine (please don't tell
me to change my OS. DOS plus MKS took-kit is all I can handle).

cheers...shahram javey

wyle@inf.ethz.ch (Mitchell Wyle) (02/12/91)

In <1991Feb12.015036.8245@hybrid.UUCP> 
javey@hybrid.UUCP (shahram javey) says:

>I don't have access to indent. I use vi on my DOS machine (please don't tell
>me to change my OS. DOS plus MKS took-kit is all I can handle).

In the simtel20 dos archives, I found the following entries under "C"

INDENT.ARC        37k  26.02.89  Indents 'C' programs (EXE and DOC, no source)
INDENTSR.ARC      62k  06.01.90  Indents 'C' programs (C source only, no EXE)

PPC.ARC           15k  02.10.88  'Pretty Printer' for 'C' language sources

There are plenty of simtel20 mirror systems around if you can't ftp directly.

I repeat: 

Use indent(1), Shahram!  ;-)

-Mitch

mrd@ecs.soton.ac.uk (Mark Dobie) (02/13/91)

In <24593@neptune.inf.ethz.ch> wyle@inf.ethz.ch (Mitchell Wyle) writes:

>In <1991Feb12.015036.8245@hybrid.UUCP> 
>javey@hybrid.UUCP (shahram javey) says:

>>I don't have access to indent. I use vi on my DOS machine (please don't tell
>>me to change my OS. DOS plus MKS took-kit is all I can handle).

>In the simtel20 dos archives, I found the following entries under "C"

>INDENT.ARC        37k  26.02.89  Indents 'C' programs (EXE and DOC, no source)
>INDENTSR.ARC      62k  06.01.90  Indents 'C' programs (C source only, no EXE)

>PPC.ARC           15k  02.10.88  'Pretty Printer' for 'C' language sources

>There are plenty of simtel20 mirror systems around if you can't ftp directly.

Indent is also available as part of the GNUish MSDOS project.

>I repeat: 

>Use indent(1), Shahram!  ;-)

Don't you think this is a sledgehammer to crack a nut? As I
understand, all that is needed is a quick way of formatting block
comments. I'm sure the rest of the code is fine. I would only use
indent to reformat other code which I couldn't read (eg Sun examples).
Using indent on my own code would be like implicitly accepting the
suggestions of a spelling checker on my writing - I would constantly
be correcting after it.

Anyway, I am sure block comments are used in other languages apart
from C, maybe for tables too, so a general method for lining things up
on the right in vi would be useful. Having said that, I have nothing
to offer (yet) and I agree that indent(1) is the quick solution, but
keep an eye on the rest of your code ;-).

				Mark.

-- 

Mark Dobie                              M.Dobie@uk.ac.soton.ecs (JANET)
University of Southampton		M.Dobie@ecs.soton.ac.uk (Bitnet)

lewis@tramp.colorado.edu (LEWIS WILLIAM M JR) (02/17/91)

My friend Carl Brandauer of Daemon Associates (attmail!bdaemon!carl or
....!stcvax!bdaemon!carl) suggests the following vi map! command for
aligning end of comment markers:

	map! ^[OQ ^[80a ^[72^V|C*/^M

In this example PF2 on a VT100 is used for the command which must be
entered like:

	^V<ESC>80a ^V<ESC>72^V^V|C*/^V<RETURN>

The logic is simple: 

	1. Enter command mode
	2. Append 80 spaces
	3. Move to column 72
	4. Change to end of line with */ and new-line

The trick is that the pipe symbol must be preceded by two ^V's.