I want to create a highlighting group named Italic to be exactly like
Normal but with text in italic. Currently, my Normal highlighting
is set to
ctermfg=251 ctermbg=234 guifg=#cccccc guibg=#242424
My questions are:
-
Is adding
term=italicto theNormalattributes the right way
to do that?:hi Italic term=italic ctermfg=251 ctermbg=234 guifg=#cccccc guibg=#242424 -
Is it possible to do that in a generic fashion, i.e., define the
new highlighting group to match the style of the base one for any
color scheme (the above does only for my current color scheme)?
Something like:hi Italic extends Normal term=italic
To solve this issue you can create the highlighting group by script.
The function below takes three string arguments: the name of the group
to base highlighting on, the name of the group to create, and a string
containing highlighting attributes to add or overwrite.
Thus, the call
creates a new group called
Italicthat extendsNormalhighlightingby the
term=italicattribute string.Note that custom highlighting groups remain unchanged on color scheme
switching. To correct this behavior you can update the group when the
current color scheme changes: