Created
June 19, 2012 22:42
-
-
Save fabiomcosta/2956964 to your computer and use it in GitHub Desktop.
Better filetype detection for djangohtml on .html files on VIM. The default one just checks for the existence of `{%\s*\(extends\|block\)` on the first 10 lines, and sometimes, on include files for example, you dont have any of them. Thi
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
" a better htmldjango detection | |
augroup filetypedetect | |
" removes current htmldjango detection located at $VIMRUNTIME/filetype.vim | |
au! BufNewFile,BufRead *.html | |
au BufNewFile,BufRead *.html call FThtml() | |
func! FThtml() | |
let n = 1 | |
while n < 10 && n < line("$") | |
if getline(n) =~ '\<DTD\s\+XHTML\s' | |
setf xhtml | |
return | |
endif | |
if getline(n) =~ '{%\|{{\|{#' | |
setf htmldjango | |
return | |
endif | |
let n = n + 1 | |
endwhile | |
setf html | |
endfunc | |
augroup END |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Que bom que ajudou!