Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get vim syntax highlighting to work along with concealing?

Tags:

vim

haskell

I'm using HaskellConcealPlus to conceal certain elements of Haskell code, and haskell.vim from here to get better syntax highlighting for Haskell. Below is what it looks like :

enter image description here

The problem is that the div, after being concealed, loses it's orange highlighting, which leads to inconsistency when '/' is highlighted orange, but '÷' is white, even though they're both infix operators. Is there a way to get the syntax highlighting and concealing to both work?

like image 353
Marcus Buffett Avatar asked Dec 22 '14 21:12

Marcus Buffett


People also ask

How do I enable syntax highlighting in vim?

After opening login.sh file in vim editor, press ESC key and type ':syntax on' to enable syntax highlighting. The file will look like the following image if syntax highlighting is on. Press ESC key and type, “syntax off” to disable syntax highlighting.

How do you make vi colorful?

You can change color schemes at anytime in vi by typing colorscheme followed by a space and the name of the color scheme. For more color schemes, you can browse this library on the vim website. You can enable or disable colors by simply typing "syntax on" or "syntax off" in vi.

How do I highlight in vim editor?

If you want to select the entire line in a file, press V. Now when you press k or j to go up and down, vim will select the entire line above and below your cursor. Finally, you can select text in columns by pressing ctrl+v and moving up or down the block.

How do I enable syntax highlighting in vim Mac?

If you want to toggle this on/off (without creating a . vimrc file) simply type :syntax on while in vi/vim. Save this answer.


1 Answers

As soon as parts of text get concealed they get colorized as defined by the highlighting group Conceal. :help hl-Conceal will tell you more details about the group. :highlight will show you all highlight groups and their color declarations. E.g. my conceal group looks like as shown below:

Conceal        xxx ctermfg=4 ctermbg=0 guifg=#8fa1b3 guibg=#2b303b

In order to get more decent colors you can of course set a custom color and properties for your conceal group inside your .vimrc. Below is an example which will use bold, underlined text, uses ANSI color 9 as the foreground color and ANSI color 0 as a background color for all files with an hs extension:

augroup AdjustConceal
    autocmd!
    autocmd ColorScheme *.hs highlight Conceal cterm=bold,underline ctermfg=9 ctermbg=0
augroup END

Alternatively you could simply link to an existing highlighting group. The example below would link from Conceal to Search:

augroup AdjustConceal
    autocmd!
    autocmd ColorScheme *.hs highlight link Conceal Search
augroup END
like image 183
Saucier Avatar answered Oct 31 '22 09:10

Saucier