Откуда vim знает цвет синтаксиса .hgrc?

297
HighCommander4

С помощью syntax onсинтаксиса vim выделяет мой ~/.hgrcфайл.

  • Как vim распознает этот файл?

  • Как я могу заставить vim применять ту же раскраску синтаксиса к файлу с другим именем?

1

1 ответ на вопрос

4
Thomas Dickey

vim uses a runtime script (such as /usr/share/vim/vim73/filetype.vim) which checks the filename, matches it in this case as

" Mercurial config (looks like generic config file) au BufNewFile,BufRead *.hgrc,*hgrc setf cfg 

The script is documented here: Vim documentation: filetype

You can customize your environment using similar commands (in fact the documentation recommends that you do this rather than modify the installed filetype.vim). vim's documentation refers to this as an "autocommand", and its documentation is the best place to start reading about the feature: Vim documentation: autocmd