0

When I copy a zero width space into vim, it is displayed as <200b>, instead of it being invisible:

screenshot of the zero width space

I've tried this in multiple terminal emulators and in both vim and neovim, and the character is always shown this way. Why is this? Is it possible to make vim render it as an actual invisible character?

Edit: Adding information requested in the comments to add images.

What is the result if you do in insert mode Ctrl-v U000200B1?

Result of oding in insert mode Ctrl-v U000200B1

When you go to the character inserted what is the result of the ga command?

For the zero-width space I get <<200b>> 8203, Hex 200b, Octal 20013, when inserting U000200B1 i get the following:

result of the ga command over U000200B1

videbar
  • 13
  • 3
  • What is the result if you do in insert mode Ctrl-v U000200B1? When you go to the character inserted what is the result of the ga command? – Vivian De Smedt Feb 23 '23 at 17:52
  • @VivianDeSmedt I just edited the main post to add the answers to your questions. – videbar Feb 23 '23 at 18:10
  • Welcome to [vi.se]! – D. Ben Knoble Feb 23 '23 at 18:40
  • @VivianDeSmedt in UTF-8, that's E2 80 8B, so actually C-v U00e2808b, which is invisible – D. Ben Knoble Feb 23 '23 at 18:45
  • I think the copy from that side is giving you a UTF-16 encoding, since the Unicode codepoint (200b) is encoded in UTF-16 as the same sequence. – D. Ben Knoble Feb 23 '23 at 18:46
  • Actually, I take all that back: yank and pasting the <200b> character into xxd gives the UTF-8 bytes; my system sees any yank starting with the C-v U00e2808b character as an empty string, probably because it's an invalid UTF-8 sequence or something. Directly writing the buffer containing that character into xxd gives a byte sequence that is probably the UTF-8 encoding of such a bizarre code point. So it seems Vim's u and U input methods after C-v are using Unicode code points and not their encoding. – D. Ben Knoble Feb 23 '23 at 18:49
  • I have been wrong I mean U0000200b which indeed is displayed as <200b> – Vivian De Smedt Feb 23 '23 at 19:10
  • 1
    Or more simply u200b. It seems to me that Vim can't display it and choose to show the Unicode code. – Vivian De Smedt Feb 23 '23 at 19:27

0 Answers0