How to make vim apply /var/log/messages syntax highlighting to any file called “messages” or “messages-*”?

When you have the file open, you can run:

:set filetype=messages

add a line in ~/.vim/ftdetect/filetype.vim

au BufNewfile,BufRead messages-* set filetype=messages