-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathfiletype.vim
37 lines (34 loc) · 857 Bytes
/
filetype.vim
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
" my filetype file
if exists("did_load_filetypes")
finish
endif
augroup filetypedetect
au BufNewFile,BufRead *.cpt call <SID>FTCheck_html()
au BufNewFile,BufRead *.cpy,*.vpy setf python
au BufNewFile,BufRead *.dbk,*.xml call <SID>FTCheck_docbook()
augroup END
" runtime! ftdetect/*.vim
" Distinguish between HTML and XHTML
" (copied from /usr/share/vim/vim63/filetype.vim )
fun! <SID>FTCheck_html()
let n = 1
while n < 10 && n < line("$")
if getline(n) =~ '\<DTD\s\+XHTML\s'
setf xhtml
return
endif
let n = n + 1
endwhile
setf html
endfun
" (adapted from /usr/share/vim/vim63/filetype.vim )
" Match case-agnostic regexp.
fun! <SID>FTCheck_docbook()
if getline(1) . getline(2) . getline(3) =~? '<!DOCTYPE.*DocBook'
let b:docbk_type="xml"
setf docbk
else
setf xml
endif
sy on
endfun