Scripting: formatlist()

Features wanted...
Post Reply
altoclef
Posts: 99
Joined: 12 Oct 2012 18:54
Location: Win11 24H2 @100%

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
To see the attached files, you need to log into the forum.

highend
Posts: 14954
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

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: 99
Joined: 12 Oct 2012 18:54
Location: Win11 24H2 @100%

Re: Scripting: formatlist()

Post by altoclef »

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

formatlist2.PNG

If there is a more elegant solution please let me know.
To see the attached files, you need to log into the forum.

highend
Posts: 14954
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: Scripting: formatlist()

Post by highend »

Code: Select all

    $foo = regexreplace(
        <<<'

            item1



			item2

        '
        , "^\s+|^(\r?\n|$)"
        );
    text $foo;
regex.png
To see the attached files, you need to log into the forum.
One of my scripts helped you out? Please donate via Paypal

altoclef
Posts: 99
Joined: 12 Oct 2012 18:54
Location: Win11 24H2 @100%

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