I would like to enter a new list item when I press enter, when I’m in a markdown list. The following code does this.
// Insert new list item in markdown
{ "keys": ["enter"], "command": "insert_snippet", "args": {"contents": "\n* "}, "context":
[
{ "key": "selector", "operator": "equal", "operand": "text.html.markdown markup.list.unnumbered.markdown meta.paragraph.list.markdown" },
{ "key": "following_text", "operator": "regex_contains", "operand": "^(?:\t| |\\)|]|;|\\}|$)", "match_all": true }
]
},
However, I would like to end the list and delete the last line (which contains just *
) if I press enter without writing anything down.
* List item
* |
After pressing enter:
* List item
|
How would I achieve this?
The only way I’ve thought of is if I can negate the following_text
command with \n*
as the argument, a new list item will not be created if I press enter when there is a blank line with *
in it. However, I don’t know how to remove the last line.