Michael
Michael

Reputation: 1963

Unclosed brackets highlight color in Vim

How can I customize the highlight color for the unclosed bracket in Vim? This is how Vim highlights an unclosed bracket when the cursor is not over the same line as the bracket:

enter image description here

This is nice, but when I move the cursor over the line where the bracket lies, this is how it looks:

enter image description here

Now, I barely can see where the bracket is. How can I change this? By the way, I'm using :set cursorline option to highlight the current line.

Upvotes: 1

Views: 551

Answers (1)

romainl
romainl

Reputation: 196476

The CursorLine highlight group has more "weight" than other highlight groups, including Error which can lead to that kind of situation where the background color of Error is overruled.

The solution I've found while working on my colorscheme is to set the foreground and background colors of Error to the inverse of what I want: red on black vs black on red and use the reverse value for cterm and gui:

hi Error ctermbg=NONE ctermfg=131 guibg=NONE guifg=#af5f5f cterm=reverse gui=reverse

And make sure CursorLine doesn't set any foreground color:

  hi CursorLine ctermbg=236 ctermfg=NONE guibg=#303030 guifg=NONE cterm=NONE gui=NONE

It works pretty well:

Error

You'll need to edit the colorscheme you are using and, if possible, send a pull request to its author.

Upvotes: 3

Related Questions