serhii.net

In the middle of the desert you can say anything you want

21 Jan 2022

Obsidian show trailing spaces in editor through custom CSS

After enabling “strict” newlines for markdown/hugo conformity I had to decide whether newline would be two trailing space or a single backspace (Line breaks in markdown)

Backspaces didn’t work out, so whitespaces it is - how to make them visible when editing?

Obsidian forum1 provided this wonderful snippet:

.cm-trailing-space-new-line, .cm-trailing-space-a, .cm-trailing-space-b, .cm-tab{
  font-size: 0;
}
.cm-trailing-space-a::before, .cm-trailing-space-b::before, .cm-trailing-space-new-line::before, .cm-tab::before{
  content:'·';
  color:var(--text-faint);
  font-size: initial;
}
.cm-trailing-space-new-line::before {
  content:'↵';  
}
.cm-tab::before {
  content:'⟶'
}

Works!

2022-01-21-124003_355x59_scrot.png

(And shows tabs as bonus, perfect.)

Nel mezzo del deserto posso dire tutto quello che voglio.
comments powered by Disqus