Page 1 of 1

Reformat paragraph based on block selection

Posted: Fri Jul 23, 2004 5:25 pm
by dknoll
When adding multiline block comments to code one often has the need to adjust both the left and right margins of the comment block. One might want to align the left margin of the comments with the indentation of the code. Similarly, the right margin of the comment block is usually aligned with some fixed column positon, say 80 charaters.

It would be cool to be able to reformat such a comment block and have it preserve the margins.

I imagine it would work like this:
1. Select a block of text.
2. The left and right edges of the selected block define left and right margins of the resulting reformatted paragraph.
3. If the left edge of the selected block is to the right of column position 1 then precede the reformatted lines with spaces to create a right shifted left margin.
4. The top and bottom lines of the selected block determine which lines are to be reformatted. All the text on these lines is reformatted

Example:

This is difficult to show but imagine that the text below in all caps has been block selected.

Code: Select all

when just getting the job done is work enough, the last thing you need
is to waste time having to learn yet another computer application. your
experience wiTH OTHER TOOLS SHOULD BE RELEVANT TO EACH NEw application,
making it posSIBLE TO SIT DOWN AND USE THAT NEW APPLICATIon right away.
that's why teXTPAD IS SO POPULAR. WHETHER YOU SIMPLY NEED a powerful
replacement fOR NOTEPAD, A TOOL FOR EDITING YOUR WEB PAGEs, or a
programming iDE, TEXTPAD DOES WHAT YOU WANT, THE WAY YOU would expect.
it's available from this web site on a try before you buy basis, so
please download your trial copy now, and find out just how productive
After applying this new reformatting command the text would look like this:

Code: Select all

when just getting the job done is work enough, the last thing you need
is to waste time having to learn yet another computer application. your
             experience with other tools should be
             relevant to each new application, making it
             possible to sit down and use that new
             application right away. that's why textpad
             is so popular. whether you simply need a
             powerful replacement for notepad, a tool for
             editing your web pages, or a programming
             ide, textpad does what you want, the way you
             would expect.
it's available from this web site on a try before you buy basis, so
please download your trial copy now, and find out just how productive
Notice that any text to the left or right of the block selection gets included in the reformatted paragraph.

Comments?

i agree

Posted: Thu Apr 07, 2005 3:13 pm
by jrsheehan
This is necessary.

Tools like Slickedit have features similar, and since Slickedit has a programmable macro language, making this tool is very easy. I often find myself opening up code in Slickedit if I want to make it prettier, even though I do most of my coding in Textpad