Add option to set a specific line/column width with automatic line breaks

Use case or problem

I frequently use a text editor to edit my markdown notes as plaintext with Vim keybindings, and in those environments, I like to set a defined maximum column width (80) so I can control line wrapping myself and not worry about inconsistent wrapping between editors/window sizes.

The Obsidian UI has a dynamic line/column width and automatic line-wrapping when editing w/ “Source mode” either enabled or disabled. Given the GUI width frequently sets itself to narrower than my desired width, the single linebreaks are rendered alongside the automatic ones which means my notes frequently look like this:

1 Lorem ipsum vulputate malesuada nisl libero etiam eget pulvinar
  dapibus sed
2 accumsan, hendrerit placerat blandit nulla quisque volutpat porta
  curae ac 
3 taciti. Ac et gravida a etiam porttitor etiam, sed pulvinar
  consectetur sapien
4 nam adipiscing, per integer vivamus sed nunc.

This is particularly frustrating to deal with when using Vim mode, as pressing j to jump down one visual line instead jumps me two. The only solution is to manually add line breaks wherever the automatic wrapping is occurring.

Current workaround (optional)

My preferred solution would be to add a “Max width” setting to Obisidian, which when set, triggers the following behavior:

With “Source mode” enabled…

  1. A vertical line/ruler is added at the column specified by the max width
  2. The GUI always expands to the full width allowed by the window size, and if the window is narrower than the max width, the text scrolls horizontally rather than wrapping automatically
  3. (Optional) When typing, line-breaks are added automatically to keep lines shorter than the max width (should behave similarly to Vim’s tw setting

With “Source mode” disabled…

  1. Single line-breaks are not rendered
  2. The GUI width and text wrapping continue to behave as they do now
  3. Under-the-hood, newline characters are added to ensure the underlying text file maintains a max line width of “Max width”

Related feature requests (optional)

Note: This behavior is really only relevant to me because I use Vim mode all the time. If any of this needs to be scoped to Vim mode, I’m cool with that.

TL;DR

I like my markdown files to have specific max line width, and I want Obsidian to play nice with that desire.

4 Likes

I have the exact same problem. I’ve resorted to fiddling with --file-line-width, but it’s not working great on my tablet.

@media only screen and (min-width: 500px) {
  body {
    --file-line-width: 20rem;
  }
}

@media only screen and (min-width: 750px) {
  body {
    --file-line-width: 33rem;
  }
}

@media only screen and (min-width: 1500px) {
  body {
    --file-line-width: 45rem;
  }
}

I have the same problem. I like using Obsidian, but I would like to be able to edit my Markdown files using other editors. Having an automatic line break at a defined column width would allow for more consistency between editors.

Concerning @h14h 's proposal, I think the “vertical ruler” would be impractical since Obsidian default font is not monospace, so the ruler would not be positioned at the same width for each line. However I fully agree with all other suggestions.