Scripting: formatlist()

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

Scripting: formatlist()

Post by altoclef » 12 Mar 2019 20:14

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 213 times

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

Re: Scripting: formatlist()

Post by highend » 12 Mar 2019 20:19

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

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

Re: Scripting: formatlist()

Post by altoclef » 14 Mar 2019 19:33

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

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

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

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

Re: Scripting: formatlist()

Post by highend » 14 Mar 2019 20:07

Code: Select all

    $foo = regexreplace(
        <<<'

            item1



			item2

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

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

Re: Scripting: formatlist()

Post by altoclef » 15 Mar 2019 19:29

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