As Bart mentioned, you can set all highlight groups with getcompletion('', 'highlight')
:
for l:highlightGroup in getcompletion('', 'highlight')
execute "hi " . l:highlightGroup . " ctermfg=7 ctermbg=none guifg=White guibg=none"
endfor
This will overwrite the link from each highlight group to the other though. I didn't like that since I wanted to create a color scheme by starting from a clean state with links intact. This way, I only have to define custom colors for a few "root" highlight groups and not all of their descendants.
The following only changes root highlight groups, i.e., groups that link to themselves:
for l:highlightGroup in getcompletion('', 'highlight')
" Get the group this highlight group links to
let l:linkedGroup = GetLinkTarget(l:highlightGroup)
" Only set the root highlight groups (those that don't link to others).
" This leaves links intact
if l:highlightGroup ==# l:linkedGroup
execute "hi " . l:highlightGroup . " ctermfg=7 ctermbg=none guifg=White guibg=none"
endif
endfor
function! GetLinkTarget(group)
let l:groupID = hlID(a:group)
" Get the group this highlight group links to
let l:linkedGroupID = synIDtrans(l:groupID)
let l:linkedGroupName = synIDattr(l:linkedGroupID, 'name')
return l:linkedGroupName
endfunction
As an alternative to getcompletion('', 'highlight')
, you can parse syntax list
which shows all highlight groups, where they link to, and when they're applied.