" Vim filetype plugin " Language: HTML " Maintainer: Carl Mueller, cmlr@math.rochester.edu " Last Change: October 10, 2002 " Version: 1.1 " 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/% & inoremap :!netscape file:$PWD/% & " Let % work with <...> pairs. set matchpairs+=<:> set autoindent set shiftwidth=2 set smarttab set smartindent set textwidth=0 " In normal mode, F1 inserts an html template. noremap :if strpart(getline(1),0,6) !~ "^<\[Hh]\[Tt]\[Mm]\[Ll]>"&&strpart(getline(2),0,6) !~ "^<\[Hh]\[Tt]\[Mm]\[Ll]>"0read ~/.Vim/html-template.vimnormal /<\/title\\|<\/TITLE:endif4jf>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()a " For the above, get the script closetag.vim from vim.sf.net 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 "\" 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 string = strpart(getline(line(".")),0,col(".")) if string =~ "<\[^>]\*$" normal f> endif exe "normal v\" call GoBackwardToTag() exe "normal ly/\\W\" exe "normal `pa>\" 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 string = strpart(getline(line(".")),0,col(".")) let inside = 0 if string =~ "<\[^>]\*$" normal f> let inside = 1 endif exe "normal v\" call GoBackwardToTag() exe "normal ly/\\W\" if 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 found = 2 while found > 1 exe "normal ?<\" let string = strpart(getline(line(".")),col("."),2) if string[0] == '/' let found = found + 1 elseif string !~ "!-\\\|\[Pp]>\\\|\[Bb]\[Rr]\\\|\[Ll]\[Ii]\\\|\[Hh]\[Rr]\\\|\[Ii]\[Mm]" let found = found - 1 endif endwhile endfunction noremap :call DeleteTagForward() function! s:DeleteTagForward() let string = strpart(getline(line(".")),col(".")-1,3) if string[0] == "<" && string[1] != "/" normal df> let look = strpart(string,1,2) if look[1] == " " let look = look[0] . ">" endif exe "normal /<\\/" . look . "\" normal df> endif endfunction inoremap < <> inoremap < " Auctex style mode set notimeout inoremap ;; ; 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
    kA inoremap ;C Fi inoremap ;R Fi inoremap ;H F ;I F ;M F ;   inoremap ;< < inoremap ;> > " Auctex style for the visual mode. Surrounds the region by the " appropriate pair of tags. vnoremap `>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`