Page 1 of 1

Scripting: formatlist()

Posted: 12 Mar 2019 20:14
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 1359 times

Re: Scripting: formatlist()

Posted: 12 Mar 2019 20:19
by highend
You could do what you've asked for with a regexreplace() instead...

Re: Scripting: formatlist()

Posted: 14 Mar 2019 19:33
by altoclef
Thank you for the suggestion. I've done this, which works for me:

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

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

Re: Scripting: formatlist()

Posted: 14 Mar 2019 20:07
by highend

Code: Select all

    $foo = regexreplace(
        <<<'

            item1



			item2

        '
        , "^\s+|^(\r?\n|$)"
        );
    text $foo;
regex.png
regex.png (4.87 KiB) Viewed 1310 times

Re: Scripting: formatlist()

Posted: 15 Mar 2019 19:29
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.