Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

vim conceal with more than one character

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=←
like image 666
yogsototh Avatar asked Nov 29 '11 11:11

yogsototh


1 Answers

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
like image 195
superjer Avatar answered Sep 18 '22 12:09

superjer