You can get the current settings of a highlight group with the
:highlight command. For example:
Comment xxx term=bold ctermfg=4 guifg=Blue
This will just output the text; there is (as far as I know), no VimScript function to get the same text in a string, but not all is lost, since we can use the
:redir command to redirect the output of a command to a variable.
We can then match this, and call the appropriate
Putting that all together, we end up with this function:
" Redirect output of :highlight to l:current
redir => l:current
silent highlight Comment
if l:current =~# '\(cterm\|gui\)=bold'
highlight Comment gui=none cterm=none
highlight Comment gui=none cterm=bold
And you can map this function to
noremap <F7> <Esc>:call ToggleComments()<CR>