Topic: Enhanced PADLINES.VDM (1 of 2), Read 41 times
Conf: VEDIT Macro Library
From: Christian Ziemski
Date: Tuesday, September 14, 2004 08:12 AM


Initiated by yesterdays padlines discussion in the "Converting, Translating" conference
I enhanced the original PADLINES.VDM.

The dialog features are now available also via commandline.

So Steven's request for padding to the longest line by calling Vedit via commandline
is possible this way now:

VPW -N0 -X PADLINES filename




My modifications:

- added: check for TAB characters and offering Detabbing if any TAB found
- added: N-option and optional -u options (see below)
- added: button: [Squeeze] to remove trailing whitespace

- fixed: Scan longest line was one character too long

- removed restriction to -N > 8 (what has that been for?)
- removed (commented out) restriction to >20 (what has that been for?)
- removed/commented out one usage of #104 in loop(what has that been for?)



So the long description now reads:
Description:    Checks for TABs in the file and offers to convert them to spaces.
Prompts for the desired line length, which should be equal
to or greater than the longest line in the file. It then
adds spaces at the end of each line to pad it to the
desired length. All lines will then have the same length.

The Windows version can "Scan" the current file to
determine the longest line; the suggested value will then
pad all lines to this length.
And it can "Squeeze" the lines by removing trailing whitespace.

A warning is given if an existing line is longer than the
desired column number; you are then prompted to ignore it,
truncate the line, or to stop.

From OS: VPW -Nn [-w] -X PADLINES filename [-u [squeeze] [detab] [truncate]]

The line length 'n' is specified by the parameter -Nn.
If n=0 the file is padded to the longest line length.

The optional parameters after -u are doing the following:

squeeze: trailing whitespace is removed before the padding is done.

detab: possible existing TAB characters are converted
to spaces before the padding is done.

truncate: if there are lines longer than 'n' they are silently
truncated to 'n' characters. Otherwise there will
be a message window.

When the end of file is reached, the file is saved and
Vedit terminates.

The optional parameter "-w" hides the File Selector window.




http://ziemski.privat.t-online.de/vedit/macros/padlines.vdm


Christian

 


Topic: Enhanced PADLINES.VDM (2 of 2), Read 41 times
Conf: VEDIT Macro Library
From: Christian Ziemski
Date: Wednesday, September 15, 2004 04:28 AM


Finally I remembered the correct word and I replaced "squeeze" by "trim" in the macro.

And I modified the parameters a bit.

The parameter -Nn is now optional.
If it is omitted it is handled like -N0. That is: pad to the longest line.

The usage from commandline is

VPW [-Nn] [-w] -X PADLINES filename [-u [trim] [detab] [truncate]]



So the easiest way for padding to the longest line by calling Vedit via commandline is now:

VPW -X PADLINES filename



http://ziemski.privat.t-online.de/vedit/macros/padlines.vdm


Christian