Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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?

share|improve this question
add comment

2 Answers

up vote 10 down vote accepted

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
share|improve this answer
    
BRILLIANT! I'll be using "messages*", but this is exactly what I wanted. I love it. Thank you so much. –  ryran Jun 28 '12 at 0:59
add comment

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

au BufNewfile,BufRead messages-* set filetype=messages
share|improve this answer
    
Thanks for responding chris. Didn't work for me. –  ryran Jun 28 '12 at 1:01
    
chris, did you mean ftdetect.vim? –  Stefan Majewsky Sep 12 '12 at 11:57
    
No, ~/.vim/ftdetect/ is a directory, ~/.vim/filetype.vim, all au BufNewfile,BufRead ... set ft=.. can put in this file. more simple. –  NagatoPain Sep 12 '12 at 22:43
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.