I have an auto command that changes some color scheme values so I can avoid forking them when all I need is small changes:

augroup FixColorSchemes
    autocmd ColorScheme *
        \ highlight EndOfBuffer guibg=bg guifg=bg |
        \ highlight FoldColumn guibg=bg |
        \ highlight! link Folded FoldColumn |
        \ highlight MatchParen guibg=bg guifg=red gui=bold |
        \ highlight SpecialKey guibg=bg |
        \ highlight TermCursorNC guibg=bg guifg=bg
augroup END

I would like the background of the column separating vertical splits to have the same color of the Normal highlight's background, and its foreground to be the same color of the background of the status line (so I would get a thin line the same color of the status line). This is what I'm trying

\ let s:output = execute('highlight ' . 'StatusLineNC') |
\ let s:reverse = matchstr(s:output, 'inverse\|reverse') |
\ echo s:reverse |
\ let s:splitcolor = s:reverse == ''
    \ ? matchstr(s:output, 'guibg' . '=\zs\S*')
    \ : matchstr(s:output, 'guifg' . '=\zs\S*') |
\ highlight! VertSplit guibg=bg guifg=s:splitcolor

It seems to work, but the colour returned, although is part of the current color scheme, is not necessarily a color used in the status line. Any idea why it doesn't work as expected?


1 Answer 1


I tried it manually and the last line gave me this error:

E254: Cannot allocate color s:splitcolor

So the guifg value isn't set to anything. (The guibg value is set so that may explain why you noticed some change to the VertSplit appearance.)

The problem is that this command doesn't evaluate the parameter values unlike, for example, the way :echo s:splitcolor will evaluate unrecognized symbols.

Scenarios like this are almost always solved by using :exe which will evaluate everything passed to it before executing the result.

:exe 'highlight! VertSplit guibg=bg guifg=' . s:splitcolor

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.