preservim / vim-markdown

Markdown Vim Mode
4.69k stars 524 forks source link

Auto Indent in code blocks #577

Open xyecoding opened 2 years ago

xyecoding commented 2 years ago

Is there a method for auto indent in the code blcoks. Like python, auto indent after :.

alerque commented 2 years ago

Are you talking about the indent level of the whole block itself or for various indents inside the block according to the content language?

xyecoding commented 2 years ago

various indents inside the block according to the content language

various indents inside the block according to the content language

alerque commented 2 years ago

I think that would be completely out of scope for this plugin. You can switch to a different file type and hence language mode so such niceties could be handled by the respective language plugin(s), but I don't see how this plugin could be expected to handle language specific things like that.

Maybe there is something I'm missing here, do you know of any other plugin that does this for embeded languages?

xyecoding commented 2 years ago

I think that would be completely out of scope for this plugin. You can switch to a different file type and hence language mode so such niceties could be handled by the respective language plugin(s), but I don't see how this plugin could be expected to handle language specific things like that.

Maybe there is something I'm missing here, do you know of any other plugin that does this for embeded languages?

No. I am new to vim. I am trying to config my vim these days. prettier seems can format the embedded language in markdown. So, I think it would be nice, if there is any plungin can auto indent in code blocks.

alerque commented 2 years ago

It can "format" the code as in indent and other similar things or it can just syntax highlight it?

xyecoding commented 2 years ago

It can "format" the code as in indent and other similar things or it can just syntax highlight it?

It is a formater used by vim-autoformat or neoformat

xyecoding commented 2 years ago

You could use one of the Prettier Vim plug-ins to run Prettier on Markdown files to utilize the embedded language feature you have mentioned.

Note that Prettier does not seem to support Python auto-formatting, so Prettier will not auto-format your Python code blocks. The supported languages (like JSON) should work, though.

Thank you for your advice!