问题
Actually I'd like to display ->
with →
(there is a space after the arrow) in haskell files. But I have the impression the conceal mechanism only work to replace ->
by one character. An undesirable effect is visually bad indentation.
Is there a way to achieve this?
Thanks.
Edit: Actually I use this, (from haskell.vim
(conceal enhancement) plugin)
syntax match hsNiceOperator "<-" conceal cchar=←
回答1:
I do exactly what you want in C. The trick is to conceal each character separately, like so:
syn match ArrowHead contained ">" conceal cchar=▶
syn match ArrowTail contained "-" conceal cchar=─
syn match ArrowFull "->" contains=ArrowHead,ArrowTail
You might find that ArrowHead or ArrowTail gets matched outside an ArrowFull, unfortunately. This is because existing syntax rules use contains=ALLBUT,...
or something similar.
To fix this in C, I added ArrowTail and ArrowHead to the cParenGroup cluster, which seems to prevent any problems.
syn cluster cParenGroup add=ArrowTail,ArrowHead
You may need to do something similar for Haskell.
Since I don't use the conceal feature at all otherwise, I tell Vim to go ahead and "conceal" the arrows ALL the time:
set conceallevel=1 concealcursor=nvic
BTW if you don't like the default colors for the conceal chars, you can change them like this:
hi conceal ctermfg=DarkBlue ctermbg=none guifg=DarkBlue guibg=none
来源:https://stackoverflow.com/questions/8309815/vim-conceal-with-more-than-one-character