I started off with the following line in my vimrc:
This applies a highlight to the current window. However, if I split a new window, that window will not have the highlight applied to it. I want the highlight to be applied to every new window as well.
This is what I currently have in my vimrc:
autocmd BufWinEnter * let w:matchId = matchadd(...) autocmd BufWinLeave * call matchdelete(w:matchId)
This gets the job done. However, it can lead to duplicate entries in the list of highlights given by
getmatches(). The issue is that
BufWinLeave does not trigger if the buffer that is being left is open in another window. As such, its entry does not get deleted.
I've tried using similar events to trigger the
matchdelete() actions, and this is as close as I've gotten to the desired functionality.