markdown-preview-enhanced
markdown-preview-enhanced copied to clipboard
customize the code block long line wrap.
I always use this fabulous package. I like to use code block most. I want code block fold long sentences at its right ends, not scroll. I mean, I want to see all words in right side pane even in long sentences. I tried to tweak style.less file in .mume.
.markdown-preview.markdown-preview { pre[data-role="codeBlock"] {
Like, white-space, overflow-x, white-space, word-wrap, overflow-wrap several properties.
But it didn't work well for me.
How can I customeze long line wrap setting in the code blocks?
Thanks in advance.
Hello,
You almost got it. Anyone else looking for a solution:
F1 => Markdown Preview Enhanced : Customize CSS
Then, in the style.less:
.markdown-preview.markdown-preview {
pre, code {
white-space: pre-wrap;
}
}
should enable wrapping for code blocks.
Before:

After:

to basaran
It works well! Thank you so much!
Thanks @basaran !!
Do you have any idea for long line wrap with line-number? The line number and the program code are out of alignment.
Example:
$ for i in $(seq 1 10); do
echo "The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog."
done
Result:

That is expected to happen when you are soft-wrapping. If you need to keep line numbers consistent, then you need to hard-wrap. You can use one of the vscode extensions for that. You can try reflow-markdown and can customize the hard-wrap length.
I usually keep it at around 60 for markdown files and manually invoke it where I want the folding.
"reflowMarkdown.preferredLineLength": 60,

@basaran Thank you for the advice.
But it did not work for me. Can you reproduce with the following markdown?
'''sh{.line-numbers}
$ for i in $(seq 1 10); do
echo "The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog."
done
'''
Note: replace ''' with "```".
is it possible to add a backslash at the end of each broken line? So if it's a linux command I can simply ctr + c -> ctrl + v. I wouldnt need to format it later