Use case or problem
This is a very specific need, but that repeats often in my workflow.
I like the Auto-pair Markdown syntax option. However, it could benefit from being split in more atomic settings.
It will auto-pair symbols such as *
, _
and `
in a smart way:
- it will add another matching symbol after caret if there is no text before nor after. This allows the user to manually add a symbol at the start and end of a word or sentence without being bothered by unwanted extra symbols. It also allows them to write symbols without the intention to use Markdown, such as
*
for a multiplication (but then it’s recommended to usecode format
to avoid issues with unwanted formatting later) - when selecting/highlighting a word or sentence, press a symbol key will auto-surround the selection (maybe that’s done by another option, though)
Triple backtick is similar but not as smart: for instance if you have a block of code:
a = 5
and you manually enter three backticks before it, it will automatically wrap them before the code:
```
```
a = 5
Every time I have to deleted / cut / move the line containing the unwated three backticks and retype / paste / move them under the block of code.
In this case it’s better to select / highlight the block of code and type three backticks as it will trigger the auto-wrap (and it’s very good, it will automatically add a new line before and after the code once it detects 3 backticks for proper formatting).
EDIT: except where there is a line starting with #
as it will be considered as a header and then the backtick will replace selected content instead
However when facing a long block of code, it’s easier to add 3 backticks at the beginning then later at the end, than highlighting the whole block of code.
Proposed solution
In this case I’d like to enter 3 backticks and have it detect, when I enter the 3rd backtick, that there is content (non-empty line) on the next line. If so, similarly to *
, _
and single backtick, it should not add closing triple backticks, expecting user to add the closure later manually.
Currently it doesn’t care about the next line, nor even about the current line and will always wrap with closing three backticks.
Alternative
If it’s too complicated, I would be fine with an option to disable just triple backtick auto-pairing: in the case where I’m writing new code, I can always just type triple backtick manually at the end of my code block, and find it less annoying than having to delete the unwanted closing triple backticks when formatting existing text.
Current workaround (optional)
- Highlight the whole code block then enter triple backticks (or use command Insert Code Block via shortcut, the fastest way)
- Delete the unwanted closing triple backticks manually each time (by cutting the extra line with Ctrl+X)