21

I love vim's colorization of /var/log/messages, but it only works for that – the absolute filename. It doesn't work for older rotations of messages (e.g. /var/log/messages-20120610) or for messages files I get from other systems. How can I tweak this?

bahamat
  • 38,658
  • 4
  • 70
  • 103
rsaw
  • 1,006
  • 1
  • 6
  • 13

2 Answers2

38

When you have the file open, you can run:

:set filetype=messages

To automate this for all files called messages, put the following into ~/.vim/ftdetect/messages.vim:

autocmd BufNewFile,BufReadPost *messages* :set filetype=messages
Thor
  • 16,942
  • 3
  • 52
  • 69
  • 1
    BRILLIANT! I'll be using "messages*", but this is *exactly* what I wanted. I love it. Thank you so much. – rsaw Jun 28 '12 at 00:59
0

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

au BufNewfile,BufRead messages-* set filetype=messages
stardiviner
  • 191
  • 1
  • 3
  • 12