Complex ftdetect plugin
syntax, syntax-highlighting, vim
Solution
You can use getline to refine your detection based on file contents. For example, this detects XML in .tmp files:
autocmd! BufNewFile,BufRead *.tmp
\ if getline(1) =~ '<?\s*xml.*?>' |
\ setfiletype xml |
\ endif
Another approach is to add a modeline to each C/AL file.
Problem
I want to create vim syntax highlighting file for custom programming language. Namely C/AL which is internal for Dynamics NAV system. The issue is that it's impossible to detect via file extension. Historically C/AL uses *.TXT files. It also not good to highlight all *.TXT files, since some of them might contain C/AL code. I know that VIM is able to detect language not only by extension, but also by file content. And I have found some examples in official manual. However it states I can use either first approach, or second. Is it possible to combine them in one go? Where I can find an examples of such behavior? Thank you in advance!