vim-markdown icon indicating copy to clipboard operation
vim-markdown copied to clipboard

Auto Indent in code blocks

Open xyecoding opened this issue 3 years ago • 8 comments

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

xyecoding avatar Mar 31 '22 07:03 xyecoding

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

alerque avatar Mar 31 '22 08:03 alerque

various indents inside the block according to the content language

various indents inside the block according to the content language

xyecoding avatar Mar 31 '22 08:03 xyecoding

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?

alerque avatar Mar 31 '22 08:03 alerque

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.

xyecoding avatar Mar 31 '22 08:03 xyecoding

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

alerque avatar Mar 31 '22 09:03 alerque

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 avatar Mar 31 '22 11:03 xyecoding

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.

felixmde avatar Apr 13 '22 00:04 felixmde

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!

xyecoding avatar Apr 13 '22 01:04 xyecoding