qcz / vscode-text-power-tools

Text Power Tools extension for VS Code
https://marketplace.visualstudio.com/items?itemName=qcz.text-power-tools
MIT License
97 stars 14 forks source link

Padding of Number Sequences #75

Open TCWORLD opened 1 year ago

TCWORLD commented 1 year ago

Apologies if this is a feature already, I couldn't seem to find a way to do it with this extension.

When inserting a sequence of numbers on multiple lines, it would be useful to have the option to specify padding the numbers, either with 0's or such that the data added to every row is a constant width.

For example, as an alterative of inserting:

blah"0"
blah"1"
...
blah"9"
blah"10"
blah"11"

It would be possible to instead have it insert one of the following options (0 or space padding, left or right aligned):

blah"00"          blah" 0"          blah"0 "
blah"01"          blah" 1"          blah"1 "
...
blah"09"          blah" 9"          blah"9 "
blah"10"          blah"10"          blah"10"
blah"11"          blah"11"          blah"11"

This would be useful when editing files with entries organised in fixed with columns.

qcz commented 1 year ago

Thanks for the suggestion, @TCWORLD.

The problem is that the number sequence generator itself does not know how many numbers it will have to generate (it is decided by an upper layer for user input or the number of selections), so the final number is unknown.

The possible solutions are the following:

TCWORLD commented 1 year ago

Ah, that makes sense.

It could be a case of specify, pad all items to x number of characters. For example in the ones above specify when running the command that they all should be padded to 2 characters with either 0's or spaces(pre/post). Any longer strings would then either have to stay being the larger width (in which case I could just undo and rerun the command with the correct width), or truncated to the specified width.