Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change highlight color of horizontal split statusline in vim

Tags:

vim

I am using the solarized color scheme for Vim. When I open a vim session with two windows horizontally split, the horizontal split is almost invisible. On the other hand, vertical splits between windows are clearly visible

Here is a picture using the dark solarized theme on cygwin. You can see a white vertical line dividing the sidebar from the other two windows. You can also see a blank area (top window) and an area with text (bottom window). The problem is that there is effectively no visible divider between the top and bottom window. I would like this divider to be the same color as the vertical divider.

(Please note this same issue occurs with any colorscheme and when using a terminal on Ubuntu as well. Basically, no matter where I use vim the horizontal splits are not highlighted different to the background.)

enter image description here

Below are what I think are the relevant lines of solarized.vim (assuming statusline is what I want to configure). I'm just not sure how to modify them.

exe "hi! StatusLine"     .s:fmt_none   .s:fg_base1  .s:bg_base02 .s:fmt_revbb
exe "hi! StatusLineNC"   .s:fmt_none   .s:fg_base00 .s:bg_base02 .s:fmt_revbb
exe "hi! Visual"         .s:fmt_none   .s:fg_base01 .s:bg_base03 .s:fmt_revbb
exe "hi! Directory"      .s:fmt_none   .s:fg_blue   .s:bg_none
exe "hi! ErrorMsg"       .s:fmt_revr   .s:fg_red    .s:bg_none
exe "hi! IncSearch"      .s:fmt_stnd   .s:fg_orange .s:bg_none
exe "hi! Search"         .s:fmt_revr   .s:fg_yellow .s:bg_none
exe "hi! MoreMsg"        .s:fmt_none   .s:fg_blue   .s:bg_none
exe "hi! ModeMsg"        .s:fmt_none   .s:fg_blue   .s:bg_none
exe "hi! LineNr"         .s:fmt_none   .s:fg_base01 .s:bg_base02
exe "hi! Question"       .s:fmt_bold   .s:fg_cyan   .s:bg_none
if ( has("gui_running") || &t_Co > 8 )
    exe "hi! VertSplit"  .s:fmt_none   .s:fg_base00 .s:bg_base00
else
    exe "hi! VertSplit"  .s:fmt_revbb  .s:fg_base00 .s:bg_base02
endif

EDIT: I attempted to use the commands suggested by Steve and it appears my problem is somehow much deeper. I set the following variables but it only colored the separators around the sidebar. Still nothing changed about the horizontal split. Anyone know what is going on here?

exe "hi! StatusLine"     .s:fmt_none   .s:fg_red  .s:bg_red .s:fmt_revbb
exe "hi! StatusLineNC"   .s:fmt_none   .s:fg_red    .s:bg_red
exe "hi! VertSplit"  .s:fmt_revbb  .s:fg_red .s:bg_red

enter image description here

EDIT2: I pulled apart my .vimrc file and isolated the problem to these lines. Once these lines are commented out the horizontal splits are styled just like the vertical ones by default....Oops!

set statusline=                                        " Override default
set statusline+=%2*\ %f\ %m\ %r%*                      " Show filename/path
set statusline+=%3*%=%*                                " Set right-side status info after this line
set statusline+=%4*%l/%L:%v%*                          " Set <line number>/<total lines>:<column>
set statusline+=%5*\ %*                                " Set ending space
like image 369
Fonnae Avatar asked Jul 23 '14 01:07

Fonnae


2 Answers

Actually the Horizontal Split is StatusLineNC

Setting it to

exe "hi! StatusLineNC"   .s:fmt_none   .s:fg_red .s:bg_base02 .s:fmt_revbb

And the Vsplit line to

   exe "hi! VertSplit"  .s:fmt_none   .s:fg_red .s:bg_red

Makes it look like the following. Not entirely visible but play with the colors.

enter image description here

EDIT: Using https://github.com/Rykka/colorv.vim/ to show the colors in line made it easier to see whch color was what.

like image 190
Steve Avatar answered Oct 16 '22 21:10

Steve


Regarding how to style the statusline without ruining the colors, the '%[num]*' sequences in your statusline is making it switch from the StatusLine highlight to the User[num] highlight. If you remove those (or define the relevant highlights) you can use the customized statusbar without breaking highlighting.

From :help 'statusline'

 * -  Set highlight group to User{N}, where {N} is taken from the
      minwid field, e.g. %1*.  Restore normal highlight with %* or %0*.
      The difference between User{N} and StatusLine  will be applied
      to StatusLineNC for the statusline of non-current windows.
      The number N must be between 1 and 9.  See |hl-User1..9|
like image 37
Drew Avatar answered Oct 16 '22 20:10

Drew