Page 1 of 1

Flexible 'alignment' function

Posted: Fri May 09, 2003 12:44 pm
by Nial
When writing code/VHDL (I'm a hardware designer) it's imortant to make things neat and readable. Part of this can involve vertically aligning lists, or series of assignments.

An example....

port map(
wraddress => ram_wr_address,
data=> ram_din,
wren=> ram_1_wren,
wrclock=> clk,
wrclken=> enabled,
rdaddress => ram_rd_address,
rdclock=> clk,
rden=> enabled,
rdclken=> enabled,
q=> ram_1_dout
);

isn't nearly as easy to scan as

port map(
wraddress.....=> ram_wr_address,
data..............=> ram_din,
wren.............=> ram_1_wren,
wrclock.........=> clk,
wrclken.........=> enabled,
rdaddress.....=> ram_rd_address,
rdclock..........=> clk,
rden.............=> enabled,
rdclken.........=> enabled,
q..................=> ram_1_dout
);

(I've had to put in '.'s so the spaces aren't cut out, and this is badly aligned but I hope you get the jist)

...and these are two very short examples, with much longer lists it can take ages getting things tidy.

Prism (that I mentioned below) has an 'alignment' feature where you can select a block of text and what's being aligned ( => in the example above) and it simply right justify aligns all the examples to the one farthest to the right. The ability to select what's used for the alignment allows this function to be used in all sorts of situations.

This shouldn't be hard to implement, but can save a _lot_ of time.

Go on, you know you want it....

Posted: Fri May 09, 2003 12:51 pm
by CJ
    I agree with you. This would be a great feature. I've tried to use the tab settings within the document class options to achieve something similar but without success.

    Posted: Fri May 09, 2003 10:30 pm
    by Angantyr
    That type of alignment would come in handy for us software engineers as well in variable declaration sections.

    Posted: Tue May 13, 2003 9:51 pm
    by Christopher_G_Lewis
    As a kind of work around, I use a combination of Replace, Block Edit Mode, and Shift Tab.

    Highlight the block, S&R the text that you want moved (in your case, S&R '=>' to '........=>' (... = lots of spaces)

    Switch to Block edit mode (ctrl-shift-f8)

    Highlight where you want your first => down to the last line (make it acouple of chars wide)

    Shift Tab, will highlight all the lines to EOL, and move them to the begining of where you highlighted.

    Remember to turn of Block Edit

    It's kind of hard to explane, but it does work.

    Posted: Wed May 14, 2003 9:36 pm
    by Nial
    > It's kind of hard to explane, but it does work.

    Hmm, it doesn't sound very convenient if you've a fair bit
    of tidying to do.

    There's a demonstration of the Prism feature here...

    http://www.iol.ie/~dmurray/Prism/Columnize.html

    Much easier to use.

    Nial.

    Posted: Thu Jun 12, 2003 6:55 pm
    by SecondToughest
    ok, that's frickin awesome. I cut/paste using block mode to achieve this type of effect currently, but this would be way more efficient.

    ST

    Posted: Fri Jun 13, 2003 8:13 am
    by trids
    I changed my mind (thanks for the link to the demo Nial!) ... and wish I could change my vote too!