File: html.vim

package info (click to toggle)
libtext-microtemplate-perl 0.24-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 296 kB
  • sloc: perl: 1,725; makefile: 2
file content (25 lines) | stat: -rw-r--r-- 657 bytes parent folder | download | duplicates (5)
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
" Example Code for detect *.html as tmt2html or tt2html or xhtml or html.

function! s:detect_xhtml()
    if getline(1).getline(2).getline(3) =~ '\<!DOCTYPE\s\_.\sXHTML\s'
        setfiletype xhtml
    endif
    setfiletype html
endfunction

function! s:detect_html()
    let save_cursor = getpos('.')
    call cursor(1, 1)
    if search('->', 'cn' ) > 0
        setfiletype tmt2html
    " XXX: if you have tt2html syntax, please uncomment it.
    " elseif search('\[%', 'cn') > 0
    "     setfiletype tt2html
    else
        call s:detect_xhtml()
    endif
    call setpos('.', save_cursor)
endfunction

autocmd! BufReadPost *.html call s:detect_html()