" XHTML.vim - version 1.0 - Macros and menus for xhtml documents " " Copyright 2002 by Donald J. Bindner " Permission to copy this document or make derivative works is granted " without condition. " " Inspired by a similar work by: " T Scott Urban urban@unix.mauigateway.com " " This file is program-generated, hence the general lack of comments. " " Each tag may be accessed by its short cut (and by the menu if using a gui) " in each of 3 modes. For most tags, these rules apply: " " Insert Mode: " Inserts the tag (and its closing tag when applicable) at the current " cursor position. The cursor is moved to the contents of the first " attribute when one exists or after the start tag otherwise. " " Normal Mode: " Inserts the tag (and its closing tag when applicable) on the line before " the current line. The cursor is placed as above. " " Visual Mode: " For tags having attributes, tags are placed with the highlighted region in " the contents of the first attribute (typically href or name). For tags " that do not contain attributes, the highlighted region is placed between " directly after the open tag. " " That said, lists are somewhat different. " " Lists: " When creating an ordered or unordered list in visual mode, the highlighted " lines will be individually enclosed in
  • pairs (i.e. each line " will be an item in the list). " " When a definition list is created in visual mode, the lines will be " processed similarly. The first word on each line will become the " definition term, and the remainder will be the definition description. " " Other: " The character CTRL-J has been redefined to "jump" to the next attribute " content field or the non-whitespace character after a tag closes. " " There are two commands :Quote and :Unquote that take ranges and will " quote or unquote respectively any &, <, > symbols on each line. This " makes it convenient to show html code in a page. " "---------- " " Only do this when not done yet for this buffer if exists("b:did_ftplugin") finish endif " Don't load another plugin for this buffer let b:did_ftplugin = 1 "---------- "comment tag nnoremap ;co OF i vnoremap ;co `>a -->`l inoremap ;co F i if has("gui") nnoremenu XHtml.Comment;co OF i vnoremenu XHtml.Comment;co `>a -->`l inoremenu XHtml.Comment;co F i endif "---------- "[a] tag nnoremap ;ah OF"i vnoremap ;ah `>a">`F"i if has("gui") nnoremenu XHtml.Href\ anchor;ah OF"i vnoremenu XHtml.Href\ anchor;ah `>a">`F"i endif "---------- "[a] tag nnoremap ;an OF"i vnoremap ;an `>a" />`F"i if has("gui") nnoremenu XHtml.Name\ anchor;an OF"i vnoremenu XHtml.Name\ anchor;an `>a" />`F"i endif "---------- "[img] tag nnoremap ;im O7F"i vnoremap ;im `>a" alt="" height="" width="" />`7F"i if has("gui") nnoremenu XHtml.Image;im O7F"i vnoremenu XHtml.Image;im `>a" alt="" height="" width="" />`7F"i endif "---------- "[br] tag nnoremap ;br O
    vnoremap ;br ` inoremap ;br
    if has("gui") nnoremenu XHtml.Break;br O
    vnoremenu XHtml.Break;br ` inoremenu XHtml.Break;br
    endif "---------- "[hr] tag nnoremap ;hr O
    vnoremap ;hr ` inoremap ;hr
    if has("gui") nnoremenu XHtml.Rule;hr O
    vnoremenu XHtml.Rule;hr ` inoremenu XHtml.Rule;hr
    endif "---------- "[big] tag nnoremap ;bi OF ;bi `>a`l inoremap ;bi F;bi OF;bi `>a`l inoremenu XHtml.Format.Big;bi F ;bo OF ;bo `>a`l inoremap ;bo F;bo OF;bo `>a`l inoremenu XHtml.Format.Bold;bo F ;ce O
    F ;ce `>a`l inoremap ;ce
    F;ce O
    F;ce `>a`l inoremenu XHtml.Format.Center;ce
    F ;em OF ;em `>a`l inoremap ;em F;em OF;em `>a`l inoremenu XHtml.Format.Emphasis;em F ;it OF ;it `>a`l inoremap ;it F;it OF;it `>a`l inoremenu XHtml.Format.Italic;it F ;kb OF ;kb `>a`l inoremap ;kb F;kb OF;kb `>a`l inoremenu XHtml.Format.Keyboard;kb F ;pp O

    F ;pp `>a

    `l inoremap ;pp

    F;pp O

    F;pp `>a

    `l inoremenu XHtml.Format.Paragraph;pp

    F ;pr O
    O vnoremap ;pr '>o' inoremap ;pr
    O if has("gui") nnoremenu XHtml.Format.Preformat;pr O
    O vnoremenu XHtml.Format.Preformat;pr '>o' inoremenu XHtml.Format.Preformat;pr
    O endif "---------- "[small] tag nnoremap ;sm OF ;sm `>a`l inoremap ;sm F;sm OF;sm `>a`l inoremenu XHtml.Format.Small;sm F ;st OF ;st `>a`l inoremap ;st F;st OF;st `>a`l inoremenu XHtml.Format.Strong;st F ;sb OF ;sb `>a`l inoremap ;sb F;sb OF;sb `>a`l inoremenu XHtml.Format.Subscript;sb F ;sp OF ;sp `>a`l inoremap ;sp F;sp OF;sp `>a`l inoremenu XHtml.Format.Superscript;sp F ;tt OF ;tt `>a`l inoremap ;tt F;tt OF;tt `>a`l inoremenu XHtml.Format.Typewriter;tt F ;uu OF ;uu `>a`l inoremap ;uu F;uu OF;uu `>a`l inoremenu XHtml.Format.Underline;uu F ;va OF ;va `>a`l inoremap ;va F;va OF;va `>a`l inoremenu XHtml.Format.Variable;va F ;h1 O

    F ;h1 `>a`l inoremap ;h1

    F;h1 O

    F;h1 `>a`l inoremenu XHtml.Heading.H1;h1

    F ;h2 O

    F ;h2 `>a`l inoremap ;h2

    F;h2 O

    F;h2 `>a`l inoremenu XHtml.Heading.H2;h2

    F ;h3 O

    F ;h3 `>a`l inoremap ;h3

    F;h3 O

    F;h3 `>a`l inoremenu XHtml.Heading.H3;h3

    F ;h4 O

    F ;h4 `>a`l inoremap ;h4

    F;h4 O

    F;h4 `>a`l inoremenu XHtml.Heading.H4;h4

    F ;h5 O
    F ;h5 `>a`l inoremap ;h5
    F;h5 O
    F;h5 `>a`l inoremenu XHtml.Heading.H5;h5
    F ;h6 O
    F ;h6 `>a`l inoremap ;h6
    F;h6 O
    F;h6 `>a`l inoremenu XHtml.Heading.H6;h6
    F ;ol O
    O
  • F ;ol `>o:'<,'>s/^\(\s*\)\(.*\)$/\1
  • \2<\/li>/`
      inoremap ;ol
      O
    1. F;ol O
      O
    2. F;ol `>o
    :'<,'>s/^\(\s*\)\(.*\)$/\1
  • \2<\/li>/`
      inoremenu XHtml.List.Ordered\ list;ol
      O
    1. F ;ul O
      O
    2. F ;ul `>o:'<,'>s/^\(\s*\)\(.*\)$/\1
    3. \2<\/li>/`
        inoremap ;ul
        O
      • F;ul O
        O
      • F;ul `>o
      :'<,'>s/^\(\s*\)\(.*\)$/\1
    4. \2<\/li>/`
        inoremenu XHtml.List.Unordered\ list;ul
        O
      • F ;li O
      • F ;li `>a`l inoremap ;li
      • F;li O
      • F;li `>a`l inoremenu XHtml.List.List\ item;li
      • F ;dl O
        O vnoremap ;dl `>o:'<,'>s/^\(\s*\)\(\w*\)\(\s*\)\(.*\)$/\1
        \2<\/dt>\3
        \4<\/dd>/`
        inoremap ;dl
        O if has("gui") nnoremenu XHtml.List.Definition\ list;dl O
        O vnoremenu XHtml.List.Definition\ list;dl `>o
        :'<,'>s/^\(\s*\)\(\w*\)\(\s*\)\(.*\)$/\1
        \2<\/dt>\3
        \4<\/dd>/`
        inoremenu XHtml.List.Definition\ list;dl
        O endif "---------- "[dt] tag nnoremap ;dt O
        F ;dt `>a`l inoremap ;dt
        F;dt O
        F;dt `>a`l inoremenu XHtml.List.Definition\ term;dt
        F ;dd O
        F ;dd `>a
        `l inoremap ;dd
        F;dd O
        F;dd `>a`l inoremenu XHtml.List.Definition\ desc;dd
        F ;ta O
        O vnoremap ;ta '>o' inoremap ;ta
        O if has("gui") nnoremenu XHtml.Table.Table;ta O
        O vnoremenu XHtml.Table.Table;ta '>o' inoremenu XHtml.Table.Table;ta
        O endif "---------- "[caption] tag nnoremap ;ca OF ;ca `>a`l inoremap ;ca F;ca OF;ca `>a`l inoremenu XHtml.Table.Caption;ca F ;tr OF ;tr `>a`l inoremap ;tr F;tr OF;tr `>a`l inoremenu XHtml.Table.Row;tr F ;th OF ;th `>a`l inoremap ;th F;th OF;th `>a`l inoremenu XHtml.Table.Heading;th F ;td OF ;td `>a`l inoremap ;td F;td OF;td `>a`l inoremenu XHtml.Table.Data;td F ;fo O
        O vnoremap ;fo '>o' inoremap ;fo
        O if has("gui") nnoremenu XHtml.Form.Form;fo O
        O vnoremenu XHtml.Form.Form;fo '>o' inoremenu XHtml.Form.Form;fo
        O endif "---------- "[input] tag nnoremap ;in O5F"i vnoremap ;in `>a" type="" value="" />`5F"i if has("gui") nnoremenu XHtml.Form.Input;in O5F"i vnoremenu XHtml.Form.Input;in `>a" type="" value="" />`5F"i endif "---------- "[textarea] tag nnoremap ;te OO vnoremap ;te '>o' inoremap ;te O if has("gui") nnoremenu XHtml.Form.Textarea;te OO vnoremenu XHtml.Form.Textarea;te '>o' inoremenu XHtml.Form.Textarea;te O endif "---------- "[button] tag nnoremap ;bu OF ;bu `>a`l inoremap ;bu F;bu OF;bu `>a`l inoremenu XHtml.Form.Button;bu F ;se OO vnoremap ;se '>o' inoremap ;se O if has("gui") nnoremenu XHtml.Form.Select;se OO vnoremenu XHtml.Form.Select;se '>o' inoremenu XHtml.Form.Select;se O endif "---------- "[option] tag nnoremap ;op OF"i vnoremap ;op `>a">`F"i if has("gui") nnoremenu XHtml.Form.Option;op OF"i vnoremenu XHtml.Form.Option;op `>a">`F"i endif "---------- "[abbr] tag nnoremap ;ab OF ;ab `>a`l inoremap ;ab F ;ac OF ;ac `>a`l inoremap ;ac F ;ad O
        F ;ad `>a`l inoremap ;ad
        F ;ar O7F"i vnoremap ;ar `>a" alt="" shape="" coords="" />`7F"i "---------- "[base] tag nnoremap ;ba OF"i vnoremap ;ba `>a" />`F"i "---------- "[body] tag nnoremap ;bd OO vnoremap ;bd '>o' inoremap ;bd O "---------- "[blockquote] tag nnoremap ;bl O
        O vnoremap ;bl '>o' inoremap ;bl
        O "---------- "[cite] tag nnoremap ;ci OF ;ci `>a`l inoremap ;ci F ;di O
        O vnoremap ;di '>o' inoremap ;di
        O "---------- "[frame] tag nnoremap ;fr O5F"i vnoremap ;fr `>a" src="" title="" />`5F"i "---------- "[frameset] tag nnoremap ;fs OO vnoremap ;fs '>o' inoremap ;fs O "---------- "[head] tag nnoremap ;he OO vnoremap ;he '>o' inoremap ;he O "---------- "[html] tag nnoremap ;ht OO vnoremap ;ht '>o' inoremap ;ht O "---------- "[iframe] tag nnoremap ;if OO vnoremap ;if '>o' inoremap ;if O "---------- "[link] tag nnoremap ;ln OF"i vnoremap ;ln `>a" />`F"i "---------- "[map] tag nnoremap ;ma O3F"i vnoremap ;ma `>a" alt="" />`3F"i "---------- "[meta] tag nnoremap ;me O3F"i vnoremap ;me `>a" content="" />`3F"i "---------- "[noframes] tag nnoremap ;nf O<CR>O vnoremap ;nf '>o' inoremap ;nf <CR>O "---------- "[noscript] tag nnoremap ;ns OO vnoremap ;ns '>o' inoremap ;ns O "---------- "[q] tag nnoremap ;qq OF ;qq `>a`l inoremap ;qq F ;sa OF ;sa `>a`l inoremap ;sa F ;sc OF"i vnoremap ;sc `>a">`F"i "---------- "[title] tag nnoremap ;ti OF ;ti `>a`l inoremap ;ti F ;& i&l vnoremap ;& ` inoremap ;& & "---------- "copy nnoremap ;cp i©l vnoremap ;cp ` inoremap ;cp © "---------- "lt nnoremap ;< i<l vnoremap ;< ` inoremap ;< < "---------- "gt nnoremap ;> i>l vnoremap ;> ` inoremap ;> > "---------- "[fieldset] tag nnoremap ;fi O
        O vnoremap ;fi '>o' inoremap ;fi
        O "---------- "[legend] tag nnoremap ;le OF ;le `>a`l inoremap ;le F ;la OF"i vnoremap ;la `>a">`F"i "---------- "[optgroup] tag nnoremap ;og OO vnoremap ;og '>o' inoremap ;og O " Jump to next attribute field nnoremap /\M="\\|>/e;/\S/ inoremap /\M="\\|>/e;/\S/ " HTML quoting function! s:HtmlQuote(l1,l2) let i = a:l1 while i <= a:l2 let l = getline(i) let l = substitute( l, '&', '\&', 'g' ) let l = substitute( l, '<', '\<', 'g' ) let l = substitute( l, '>', '\>', 'g' ) call setline( i, l ) let i = i+1 endwhile endfunction function! s:HtmlUnquote(l1,l2) let i = a:l1 while i <= a:l2 let l = getline(i) let l = substitute( l, '>', '>', 'g' ) let l = substitute( l, '<', '<', 'g' ) let l = substitute( l, '&', '\&', 'g' ) call setline( i, l ) let i = i+1 endwhile endfunction command! -buffer -range Quote call s:HtmlQuote(,) command! -buffer -range Unquote call s:HtmlUnquote(,)