line 1:
E216: No such group or event: ColorScheme * highlight UnwanttedTab ctermbg=red guibg=darkred
line 2:
E28: No such highlight group name: UnwanttedTab /\t/
line 3:
E216: No such group or event: ColorScheme * highlight TrailSpace guibg=red ctermbg=darkred
line 4:
E28: No such highlight group name: TrailSpace / \+$/

I was following this guide and using autocmd to prevent my highlight settings to be cleared. But still can't get to work. Does anyone know what could be wrong?

2 Answers
2

The problem with your code is that the match commands reference custom highlight group names that aren't defined yet. Those group names must be defined using e.g. highlight UnwanttedTab ...before you use them with match. The autocmds will only define the highlight group names using highlightafter you've loaded any colorscheme.

This is a way to setup the highlight groups, first defining syntax highlighting with group names, then providing a match for those group names: