To solve this problem, you can create a highlight group using a script. The function below takes three string arguments: the name of the group for the base selection, the name of the group to be created, and a string containing additional selection of properties (or properties for overwriting).
function! ExtendHighlight(base, group, add) redir => basehi sil! exe 'highlight' a:base redir END let grphi = split(basehi, '\n')[0] let grphi = substitute(grphi, '^'.a:base.'\s\+xxx', '', '') sil exe 'highlight' a:group grphi a:add endfunction
So the challenge
:call ExtendHighlight('Normal', 'Italic', 'term=italic')
creates a new group called Italic that highlights Normal highlighting the term=italic attribute string.
Note that custom highlight groups remain unchanged in the color scheme switching. To fix this behavior, you can update the group when the current color scheme changes.
:autocmd ColorScheme * call ExtendHighlight('Normal', 'Italic', 'term=italic')
source share