How to display and write all distinct white space and control characters in VS Code (or other text editor)

2.1k views Asked by At

I would like to be able to see all whitespace and control character explicitly in my text editor. Example Hi world! This is a new line! (pretend the new line is actually on a new line) as something like Hi\sworld!\nThis\sis\sa\snew\sline!. Or another example: Some people like spaces while others... like tabs (pretend there is a tab after the three periods) would render as \s\sSome\speople\slike\sspaces\swhile\sothers...\tlike\tabs How can I go about doing this? Also is there a way I can explicitly enter control characters, perhaps using their Unicode value?

I'm sure some of you will want to know why I care to do this. Hacker types would find inherent appeal but, beyond the joy of knowing, an esoteric programing language like Whitespace would be much easier to write for in VS Code if this kind of explicit control were allowed.

So. Can it be done? Are the worlds great text editors powerful and flexible enough to allow for this kind of functionality?

1

There are 1 answers

2
Prog1020 On

In CudaText (free, cross platform) I can config this. I have tweaked few options (in user.json) with names unprinted_*, here is user.json for new app install:

{
    "unprinted_show": true,
    "unprinted_content": "sed",
    "unprinted_tab_len": 0,
    "unprinted_space_dot_scale": 40,
    "unprinted_tab_ptr_scale": 40,
}

This makes space-chars - big dots (40%) and tab-chars - big arrows (40% pointer size). Here's screenshot

CudaText

I tested CudaText with all white space chars from Wikipedia list https://en.wikipedia.org/wiki/Whitespace_character#Unicode . Most are shown by one way or another, high unicode chars (0x2000+) not shown:

  • line ends 0x0A or 0x0D: shown as marker "un" or "mac" or "win" at line ends
  • tab char 0x09: shown as arrow with pale color
  • space char 0x20: shown as dot with pale color
  • char 0x0B, 0x0C: shown as "x0B", "x0C" with pale color
  • char 0x85: shown as font glyph
  • char 0xA0: shown as pale dot, like space
  • char 0x1680: shown as font glyph
  • chars 0x2000...0x200A: shown in hex form like "x200A"