I use :match to highlight problems with my code that don’t meet style guidelines. The following works great for the first window I open in Vim:
~/.vimrc:
hi ExtraWhitespace ctermbg=red guibg=red
hi NoFunctionSpace ctermbg=red guibg=red
match ExtraWhitespace /\s\+$\| \+\ze\t/
2match NoFunctionSpace /\S(/
However, when I go to :tabedit a file, or if I open Vim with the -p option and multiple files, only the first window highlights matches. I want all of my open tabs to show matches.
The
:matchcommands only apply to the current window. To automatically apply them to each new window, hook them into theWinEnterevent:You still need the original
:matchcommands, too, because theWinEnterevent isn’t fired for the initial window.