" Vim filetype plugin " Language: HTML " Maintainer: Carl Mueller, cmlr@math.rochester.edu " Last Change: December 3, 2001 " Version: 1.0 " Website: http://www.math.rochester.edu/u/cmlr/vim/syntax/index.html " This is an html mode. Typing "<" produces "<>" with the cursor in " between. After that, you should be able to do everything else with the " F1 key. There are also Auctex style macros. For example, ;1 inserts "

with the cursor in between. ;ta inserts
and " ;td inserts . noremap :!netscape file:$PWD/% & " Let % work with <...> pairs. set matchpairs+=<:> set autoindent set shiftwidth=2 set smarttab set smartindent " In normal mode, F1 inserts a latex template. noremap :if strpart(getline(1),0,6) !~ "^<\[Hh]\[Tt]\[Mm]\[Ll]>"0read ~/.Vim/html-template.vimnormal /<\/title\\|<\/TITLE:endif3jf>a " In insert mode, F1 looks back to find the last uncompleted <> tag, and " inserts the completion. It ignores uncompleted
,

,

  • , , " and their capitalized forms. F2 does the same, but puts blank lines in " between. inoremap :call OneLineCompletion()i inoremap :call ThreeLineCompletion()a inoremap 5hi inoremap 5hi inoremap 8hi inoremap 3hi inoremap 5hi inoremap 8hi inoremap 5hi " In visual mode, F1 encloses the selected region in " a pair of <>... braces. function! s:InsertTag(tag) exe "normal `>a\>\`l" endfunction vnoremap :call InsertTag(input("HTML Tag? ")) " Another way to insert the tag: inoremap :call PutInTag(input("Tag? ")) function! s:PutInTag(tag) exe "normal a<" . a:tag . "\laF<" startinsert endfunction inoremap " =Double('"','"') function! s:Double(left,right) if strpart(getline(line(".")),col(".")-2,2) == a:left . a:right return "\s" else return a:left . a:right . "\" endif endfunction " If you have just used F1 in visual mode to insert a pair of <>... " braces, you can type in what goes in the first, and then F1 will complete " it. " This function sees whether you are inside a <...> and moves you to the > " if you are. Otherwise it stays where it is. Then it completes the last " unmatched <...>, excluding

    and
    and

  • . If

    , etc. are " present, they will screw things up. function! s:OneLineCompletion() let s:string = strpart(getline(line(".")),0,col(".")) if s:string =~ "<\[^>]\*$" normal f> endif exe "normal v\" call GoBackwardToTag() exe "normal ly/\\W\" exe "normal `pF<" endfunction " This function is the same as the last, except it puts the matching " three lines down, if you are inside a <...>. function! s:ThreeLineCompletion() let s:string = strpart(getline(line(".")),0,col(".")) let s:inside = 0 if s:string =~ "<\[^>]\*$" normal f> let s:inside = 1 endif exe "normal v\" call GoBackwardToTag() exe "normal ly/\\W\" if s:inside exe "normal `\pk" else exe "normal `pl" endif endfunction " This function searches backward for the first unmatched <...> " WARNING!! It ignores

    ,
    ,

  • , , and their capitalized " versions. It will miscount if these are completed with

    , etc. " Make sure you have a or or , etc, at the start of " your file, or this function won't work. function! s:GoBackwardToTag() let s:found = 2 while s:found > 1 exe "normal ?<\" let s:string = strpart(getline(line(".")),col("."),2) if s:string[0] == '/' let s:found = s:found + 1 elseif s:string !~ "!-\\\|\[Pp]>\\\|\[Bb]\[Rr]\\\|\[Ll]\[Ii]\\\|\[Hh]\[Rr]\\\|\[Ii]\[Mm]" let s:found = s:found - 1 endif endwhile endfunction noremap :call DeleteTagForward() function! s:DeleteTagForward() let s:string = strpart(getline(line(".")),col(".")-1,3) if s:string[0] == "<" && s:string[1] != "/" normal df> let s:look = strpart(s:string,1,2) if s:look[1] == " " let s:look = s:look[0] . ">" endif exe "normal /<\\/" . s:look . "\" normal df> endif endfunction inoremap < <> inoremap < " Auctex style mode set notimeout inoremap ;; ; inoremap ;1

    4hi inoremap ;2

    4hi inoremap ;3

    4hi inoremap ;4

    4hi inoremap ;5
    4hi inoremap ;ad
    F ;ah F"i inoremap ;am F"i inoremap ;an F"i inoremap ;b
    inoremap ;c
    F ;dd
    inoremap ;dl
    o
    O inoremap ;dt
    inoremap ;e F ;f F>i inoremap ;h
    inoremap ;i 8hi inoremap ;l
  • inoremap ;o
      o
    O inoremap ;p

    inoremap ;s F ;ta o
    O inoremap ;td F ;th F ;tr oO inoremap ;u

      o
    • o
    O inoremap ;C Fi inoremap ;R Fi inoremap ;H F ;I F ;M F `>a>`v` ;ah `>a>`v` ;1 :call InsertTag("h1") vnoremap ;2 :call InsertTag("h2") vnoremap ;3 :call InsertTag("h3") vnoremap ;4 :call InsertTag("h4") vnoremap ;5 :call InsertTag("h5") vnoremap ;ad :call InsertTag("address") vnoremap ;c :call InsertTag("center") vnoremap ;dd :call InsertTag("dd") vnoremap ;dl :call InsertTag("dl") vnoremap ;dt :call InsertTag("dt") vnoremap ;e :call InsertTag("em") vnoremap ;f :call InsertTag("font") vnoremap ;o :call InsertTag("ol") vnoremap ;s :call InsertTag("strong") vnoremap ;ta :call InsertTag("table") vnoremap ;td :call InsertTag("td") vnoremap ;th :call InsertTag("th") vnoremap ;tr :call InsertTag("tr") vnoremap ;u :call InsertTag("ul") vnoremap ;C `>a -->` vnoremap ;R `>a ==>` nnoremenu 40.401 Html.template\ \ \ \ \ \ \ \ F1 :if strpart(getline(1),0,6) !~ "^<\[Hh]\[Tt]\[Mm]\[Ll]>"0read ~/.Vim/html-template.vimnormal /<\/title\\|<\/TITLE:endifi inoremenu 40.402 Html.one-line\ tag\ \ \ \ F1 :call OneLineCompletion()i inoremenu 40.403 Html.two-line\ tag\ \ \ \ F2 :call ThreeLineCompletion()a inoremenu 40.404 Html.href\ \ \ \ \ \ \ \ \ \ \ \ F3 inoremenu 40.405 Html.email\ \ \ \ \ \ \ \ \ \ \ F4 vnoremenu 40.406 Html.embrace\ \ \ \ \ \ \ \ \ F1 a `>i`$x`