Scripting: formatlist()

Features wanted...
Post Reply
altoclef
Posts: 30
Joined: 12 Oct 2012 18:54

Scripting: formatlist()

Post by altoclef »

Please would it be possible to either:
  • change the formatlist() t format switch to trim all whitespace (tabs and spaces), or
  • add a new switch which would do so?
This is so I could indent with tabs not multiple spaces, so that it matches my coding style - see image where item1 is shown as I would prefer to indent, but item2 is as I have to do so currently.

formatlist.PNG
formatlist.PNG (2.5 KiB) Viewed 1332 times

highend
Posts: 13274
Joined: 06 Feb 2011 00:33

Re: Scripting: formatlist()

Post by highend »

You could do what you've asked for with a regexreplace() instead...
One of my scripts helped you out? Please donate via Paypal

altoclef
Posts: 30
Joined: 12 Oct 2012 18:54

Re: Scripting: formatlist()

Post by altoclef »

Thank you for the suggestion. I've done this, which works for me:

formatlist2.PNG
formatlist2.PNG (3.84 KiB) Viewed 1293 times

If there is a more elegant solution please let me know.

highend
Posts: 13274
Joined: 06 Feb 2011 00:33

Re: Scripting: formatlist()

Post by highend »

Code: Select all

    $foo = regexreplace(
        <<<'

            item1



			item2

        '
        , "^\s+|^(\r?\n|$)"
        );
    text $foo;
regex.png
regex.png (4.87 KiB) Viewed 1283 times
One of my scripts helped you out? Please donate via Paypal

altoclef
Posts: 30
Joined: 12 Oct 2012 18:54

Re: Scripting: formatlist()

Post by altoclef »

Ah, I see - you meant just using regexreplace(). I didn't realise that.

I shall have a look at your solution to fully understand it.

Thank you.

Post Reply