Markdown Numbered List

Hey guys,
I wanted to duplicate and change this standard List Action from the directory to be able to toggle numbered Lists.
I set the listMark correctly and tried to adapt the expression to find out if the script should add or remove the mark, but I did not get this part to work (I’m really no js expert :D).
Can someone tell me how to toggle the mark "1. " within this action or maybe post an action to the directory which does the same thing?

Something like this ?

( Updated now for a wider button and slightly better selection handling )

More or less thank you, would be the best if it won’t select the lines and just use the current line to toggle the „1.“ because it does not matter for markdown which number is in front of the point;)

If I am understanding, you mean that you would like it to act on one line at a time ?

1 Like

( I’ve updated the behaviour for single-line selections – the selection now collapses to the end of the line in these cases )

1 Like

A Little Bit Strange If it’s the first line and sometimes if it’s the last line with text and afterwards a line without text it’s inserting a „\n“ if it’s the first line or adds a „2.“ to the last line
Thank you very much!

Thanks ! Could you give me, fenced between 3 back-ticks above and below (to avoid forum formatting side-effects),


a sample text and{^} cursor position


which seems to consistently reproduce the problem ?

(Using a {^} mark to show where the cursor is, or two of them if the selection is extended)

example 1:

my sample text{^}

result when running the action at cursor position:

1. my sample text
2. {^}

& all the text is selected

example 2:

my second sample text{^}


1. my second sample text{^}

Perfect – thank you.

I’ve made an adjustment to the editor.setText argument here:

(Let me know if that hasn’t quite fixed it yet)


Thank you @draft8 awesome work!

1 Like