Super-old question, but in case anyone else is trying to figure this out, I have had success with the following:
call matchadd('Conceal', '<-\&<', 10, -1, {'conceal':'←'})
call matchadd('Conceal', '<\zs-', 10, -1, {'conceal':' '})
hi Conceal ctermbg=NONE ctermfg=red guifg=red
The second argument of matchadd
is <pattern>
. Looking at :help pattern
tells us that a pattern
is one or more branches
separated by \|
, and a branch
is one or more concats
separated by \&
. From the docs: "[a branch
] matches the last concat
, but only if all the preceding concats
also match at the same position."
So in the first call we specify a pattern
with one branch (there are no \|
values), made of two concats
. The first concat
matches the full arrow, and the second matches the first character of the arrow. Thus, the last concat
is the <
which is all that is taken as the match for the conceal parameter, but this only matches if the <
appears in a <-
. The second call gives a pattern
with one branch
and one concat
. The pattern begins with the <
but the match is reset with the zero-width
atom \zs
which resets the match at the next character, the -
, which is concealed with a space. The hi Conceal
is just highlighting.
In my testing <
by itself doesn't get turned into ←
and -
by itself isn't turned into a space.
Hope this helps someone :)
"→ "
- it appears to be essential to the question?