New v1.0 took away "Line wrap" in the editor settings

What I’m trying to do

I don’t want my code to wrap, and was able to achieve this by toggling a “line wrap” setting before in 0.15.9. Now V1.0 took that away… OMG… such a disaster… how do I stop my code blocks from wrapping again?

A CSS snippet should be able to do it. Something like

code {white-space: pre;}

You may need to target an element that contains the code element instead.

can you post some more code? I have tried

.markdown-source-view code{
white-space: pre;
}

also

code{
white-space: pre;
}

and placed it into the obsidian.css file and loaded the snippet… it doesn’t work.

No, sorry. I don’t know that much, so I’d have to dig around and do research.

Here are some links that should help. Some of the information about specific classes will be out of date because Obsidian has recently changed its default theme, but there should be info about the basic approach to take.

https://forum.obsidian.md/t/getting-comfortable-with-obsidian-css

https://forum.obsidian.md/t/meta-post-common-css-hacks

Recent changes to Obsidian’s CSS:
https://forum.obsidian.md/t/1-0-theme-migration-guide/42537

CSS in general:

I use the following snippet in my own. Still works for 1.0.0

/* code block only - scrollbar. Editing & Reading */
	.HyperMD-codeblock, .markdown-preview-view pre code {
		white-space: pre;
	}

The outcome per screenshot. This is mobile but it also works similar for desktop. The live preview is the one where code seems to run off the screen.

2 Likes

Beautiful!

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.