When I insert a ZWNJ character into text, vim displays <200c>
instead of it.
Is it possible to make vim to behave normally with this character, like GUI editors? Or is it possible to hide (and not remove) this character in vim's display?
Vi and Vim Stack Exchange is a question and answer site for people using the vi and Vim families of text editors. It only takes a minute to sign up.
Sign up to join this communityWhen I insert a ZWNJ character into text, vim displays <200c>
instead of it.
Is it possible to make vim to behave normally with this character, like GUI editors? Or is it possible to hide (and not remove) this character in vim's display?
What you can do, is conceal characters that you want to be displayed differently. Concealing means to change how a character (or a pattern) looks like in your current window.
For your specific case, you can do this:
:call matchadd('Conceal', '\%u200c', 10, -1, {'conceal':''})
:set conceallevel=2 concealcursor=nv
The first statement sets up a conceal rule for your character ZWNJ and uses the regular expression atom /\%u
(by matching a character against its Unicode codepoint value.
The second statement sets up the actual conceal setting for your window. So it will make sure that concealed characters will be hidden in normal and visual mode (even if the cursor is on that line). For more information have a look at :help 'concealcursor'
and :help 'conceallevel'
.
Note however, this is a mere visual feature and it won't change the actual text. In fact, even the text wrapping will occur only on the physical text representation which might let the text wrapping look a bit strange. However this has been classified as no bug and probably won't change in the future.
Note also, this is a window specific setting. So it would have to be done in each window, where you like to change the visual representation. For specific filetypes, you could even convert this to a specific filetype plugin. But that is the topic of another question/answer :)
:set concealcursor+=i
Nov 13, 2018 at 7:29
conceal
the character. Try the following::call matchadd('Conceal', '<200c>', 10, -1, {'conceal':''})
:set conceallevel=2 concealcursor=nv
(the <200c> needs to be the ZWNJ character copied literally