Basically I have a long list of highlight groups that start with DevIcon (DevIconPng, DevIconJs etc.), they all come with their own ctermfg and guifg and I would like to change them to a single color.

Something like:

hi DevIcon* guifg=#123456 ctermfg=25

Is this possible, or if not, is there some workaround?


1 Answer 1


You can use the getcompletion() function to resolve all highlights starting with a specific prefix. For example:

:echo getcompletion('DevIcon', 'highlight')
['DevIconPng', 'DevIconJs', ...]

You can then use that in a for loop to act on them.

:for hl in getcompletion('DevIcon', 'highlight') | execute 'hi '.hl.' guifg=#123456 ctermfg=25' | endfor

See :help :for and :help :execute, also :help expr-. for the string concatenation.

  • Thank you so much. It works! Just a minor correction (I tried to edit myself, but couldn't since it's a small change), there should be a space after ... .hl.'guifg=... (should be ... .hl.' guifg=...). Dec 20, 2021 at 21:56
  • 1
    Sorry for the typo and thanks for spotting it! I have just fixed it myself now. Glad this worked for you!
    – filbranden
    Dec 20, 2021 at 22:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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