" Vimball Archiver by Charles E. Campbell, Jr., Ph.D. UseVimball finish MangleImageTag.vim [[[1 296 " MangleImageTag() - updates an 's width and height tags. " " Requirements: " VIM 7 or later " " Copyright (C) 2004-2008 Christian J. Robinson " " Based on "mangleImageTag" by Devin Weaver " " This program is free software; you can redistribute it and/or modify it " under the terms of the GNU General Public License as published by the Free " Software Foundation; either version 2 of the License, or (at your option) " any later version. " " This program is distributed in the hope that it will be useful, but WITHOUT " ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or " FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for " more details. " " You should have received a copy of the GNU General Public License along with " this program; if not, write to the Free Software Foundation, Inc., 59 Temple " Place - Suite 330, Boston, MA 02111-1307, USA. " " RCS info: -------------------------------------------------------------- {{{ " $Id: MangleImageTag.vim,v 1.12 2008/05/30 00:53:28 infynity Exp $ " $Log: MangleImageTag.vim,v $ " Revision 1.12 2008/05/30 00:53:28 infynity " - Clarify an error message " - Don't move the cursor when updating the tag " " Revision 1.11 2008/05/26 01:11:25 infynity " *** empty log message *** " " Revision 1.10 2008/05/01 05:01:02 infynity " Code changed for Vim 7: " - Computed sizes should always be correct now " - Code is a bit cleaner, but unfortunately slower " " Revision 1.9 2007/05/04 02:03:42 infynity " Computed sizes were very wrong when 'encoding' was set to UTF8 or similar " " Revision 1.8 2007/05/04 01:32:27 infynity " Missing quotes " " Revision 1.7 2007/01/04 04:29:55 infynity " Enclose the values of the width/height in quotes by default " " Revision 1.6 2006/09/22 06:25:14 infynity " Search for the image file in the current directory and the buffer's directory. " " Revision 1.5 2006/06/09 07:56:08 infynity " Was resetting 'autoindent' globally, switch it to locally. " " Revision 1.4 2006/06/08 04:16:17 infynity " Temporarily reset 'autoindent' (required for Vim7) " " Revision 1.3 2005/05/19 18:31:31 infynity " SizeGif was returning width as height and vice-versa. " " Revision 1.2 2004/03/22 10:04:24 infynity " Update the right tag if more than one IMG tag appears on the line. " " Revision 1.1 2004/03/22 05:58:34 infynity " Initial revision " ------------------------------------------------------------------------ }}} if v:version < 700 || exists("*MangleImageTag") finish endif function! MangleImageTag() "{{{1 let start_linenr = line('.') let end_linenr = start_linenr let col = col('.') - 1 let line = getline(start_linenr) if line !~? ']*$' let end_linenr = end_linenr + 1 let line = line . "\n" . getline(end_linenr) endwhile " Make sure we modify the right tag if more than one is on the line: if line[col] != '<' let tmp = strpart(line, 0, col) let tagstart = strridx(tmp, '<') else let tagstart = col endif let savestart = strpart(line, 0, tagstart) let tag = strpart(line, tagstart) let tagend = stridx(tag, '>') + 1 let saveend = strpart(tag, tagend) let tag = strpart(tag, 0, tagend) if tag[0] != '<' || col > strlen(savestart . tag) - 1 echohl ErrorMsg echomsg "Cursor isn't on an IMG tag." echohl None return endif if tag =~? "src=\\(\".\\{-}\"\\|'.\\{-}\'\\)" let src = substitute(tag, ".\\{-}src=\\([\"']\\)\\(.\\{-}\\)\\1.*", '\2', '') if tag =~# 'src' let case = 0 else let case = 1 endif else echohl ErrorMsg echomsg "Image src not specified in the tag." echohl None return endif if ! filereadable(src) if filereadable(expand("%:p:h") . '/' . src) let src = expand("%:p:h") . '/' . src else echohl ErrorMsg echomsg "Can't find image file: " . src echohl None return endif endif let size = s:ImageSize(src) if len(size) != 2 return endif if tag =~? "height=\\(\"\\d\\+\"\\|'\\d\\+\'\\|\\d\\+\\)" let tag = substitute(tag, \ "\\c\\(height=\\)\\([\"']\\=\\)\\(\\d\\+\\)\\(\\2\\)", \ '\1\2' . size[1] . '\4', '') else let tag = substitute(tag, \ "\\csrc=\\([\"']\\)\\(.\\{-}\\|.\\{-}\\)\\1", \ '\0 ' . (case ? 'HEIGHT' : 'height') . '="' . size[1] . '"', '') endif if tag =~? "width=\\(\"\\d\\+\"\\|'\\d\\+\'\\|\\d\\+\\)" let tag = substitute(tag, \ "\\c\\(width=\\)\\([\"']\\=\\)\\(\\d\\+\\)\\(\\2\\)", \ '\1\2' . size[0] . '\4', '') else let tag = substitute(tag, \ "\\csrc=\\([\"']\\)\\(.\\{-}\\|.\\{-}\\)\\1", \ '\0 ' . (case ? 'WIDTH' : 'width') . '="' . size[0] . '"', '') endif let line = savestart . tag . saveend let saveautoindent=&autoindent let &l:autoindent=0 call setline(start_linenr, split(line, "\n")) let &l:autoindent=saveautoindent endfunction function! s:ImageSize(image) "{{{1 let ext = fnamemodify(a:image, ':e') if ext !~? 'png\|gif\|jpe\?g' echohl ErrorMsg echomsg "Image type not recognized: " . tolower(ext) echohl None return endif if filereadable(a:image) let ldsave=&lazyredraw set lazyredraw let buf=readfile(a:image, 'b', 1024) let buf2=[] let i=0 for l in buf let string = split(l, '\zs') for c in string let char = char2nr(c) call add(buf2, (char == 10 ? '0' : char)) " Keep the script from being too slow, but could cause a JPG " (and GIF/PNG?) to return as "malformed": let i+=1 if i > 1024 * 4 break endif endfor call add(buf2, '10') endfor if ext ==? 'png' let size = s:SizePng(buf2) elseif ext ==? 'gif' let size = s:SizeGif(buf2) elseif ext ==? 'jpg' || ext ==? 'jpeg' let size = s:SizeJpg(buf2) endif else echohl ErrorMsg echomsg "Can't read file: " . a:image echohl None return endif return size endfunction function! s:SizeGif(lines) "{{{1 let i=0 let len=len(a:lines) while i <= len if join(a:lines[i : i+9], ' ') =~ '^71 73 70\( \d\+\)\{7}' let width=s:Vec(reverse(a:lines[i+6 : i+7])) let height=s:Vec(reverse(a:lines[i+8 : i+9])) return [width, height] endif let i+=1 endwhile echohl ErrorMsg echomsg "Malformed GIF file." echohl None return endfunction function! s:SizeJpg(lines) "{{{1 let i=0 let len=len(a:lines) while i <= len if join(a:lines[i : i+8], ' ') =~ '^255 192\( \d\+\)\{7}' let height = s:Vec(a:lines[i+5 : i+6]) let width = s:Vec(a:lines[i+7 : i+8]) return [width, height] endif let i+=1 endwhile echohl ErrorMsg echomsg "Malformed JPEG file." echohl None return endfunction function! s:SizePng(lines) "{{{1 let i=0 let len=len(a:lines) while i <= len if join(a:lines[i : i+11], ' ') =~ '^73 72 68 82\( \d\+\)\{8}' let width = s:Vec(a:lines[i+4 : i+7]) let height = s:Vec(a:lines[i+8 : i+11]) return [width, height] endif let i+=1 endwhile echohl ErrorMsg echomsg "Malformed PNG file." echohl None return endfunction function! s:Vec(nums) "{{{1 let n = 0 for i in a:nums let n = n * 256 + i endfor return n endfunction " vim:ts=4:sw=4: " vim600:fdm=marker:fdc=2:cms=\ \"%s: bitmaps/Blist.xpm [[[1 29 /* XPM */ static char *Blist[] = { /* width height num_colors chars_per_pixel */ " 20 20 3 1", /* colors */ ". c #000000", "# c None", "a c #ffffff", /* pixels */ "####################", "####################", "####################", "####.###############", "###.a.##.........###", "####.###############", "####################", "####################", "####################", "####.###############", "###.a.##.........###", "####.###############", "####################", "####################", "####################", "####.###############", "###.a.##.........###", "####.###############", "####################", "####################"}; bitmaps/Bold.xpm [[[1 28 /* XPM */ static char *Bold[] = { /* width height num_colors chars_per_pixel */ " 20 20 2 1", /* colors */ ". c #333366", "# c None", /* pixels */ "####################", "####################", "####################", "#########..#########", "#########..#########", "########....########", "########....########", "#######......#######", "#######......#######", "######..##....######", "######..##....######", "#####..####....#####", "#####..####....#####", "####............####", "####..######....####", "###..########....###", "##...########....###", "#.....#####........#", "####################", "####################"}; bitmaps/Break.xpm [[[1 25 /* XPM */ static char * Break_xpm[] = { "20 20 2 1", " c None", ". c #000000", " ", " ", " ", " ", " ", " .. ", " .. ", " .. ", " . .. ", " .. .. ", " .............. ", " ............... ", " .............. ", " .. ", " . ", " ", " ", " ", " ", " "}; bitmaps/Browser.xpm [[[1 28 /* XPM */ static char * Browser_xpm[] = { "20 20 5 1", " c None", ". c #FFFFFF", "+ c #CCFFFF", "@ c #009933", "# c #000000", " ###### ", " ##@@@@@@## ", " ##.@...@...@## ", " #@@..@@@@@@@.@@# ", " #.@.@@..@@@@@.@# ", " #@.@@.@.@.@.@.@.@# ", " #@@@..@@.@..@..@.# ", "#@..@.@..@@..@..@@@#", "#@..@@...@@.@.@.@@.#", "#@..@@..@..@@@@@.@.#", "#@.@@.@@...@..@..@.#", "#@@@...@...@..@..@.#", "#@@....@@@@@..@..@@#", " #@@..@...@@@@@@@@# ", " #..@@@...@...@..@# ", " #..@@...@...@..# ", " #..@.@@@@...@@@# ", " ##@...@@@@@@## ", " ##..@...## ", " ###### "}; bitmaps/Firefox.xpm [[[1 74 /* XPM */ static char * Firefox_xpm[] = { "20 20 51 1", " c None", ". c #111C42", "+ c #621F36", "@ c #3A76A2", "# c #4E6E7E", "$ c #F8DD11", "% c #657B81", "& c #274161", "* c #F4B41B", "= c #6A163E", "- c #6A321E", "; c #8E8B63", "> c #1E69A5", ", c #ACA270", "' c #BA300F", ") c #9E7E38", "! c #8E553A", "~ c #9A9242", "{ c #C4450F", "] c #2D8FCD", "^ c #DD7319", "/ c #4E5E75", "( c #9A5222", "_ c #AE8E5A", ": c #F9D744", "< c #860E2A", "[ c #D1A737", "} c #A26A46", "| c #E8961C", "1 c #367AB2", "2 c #419CD0", "3 c #CB5317", "4 c #1D518A", "5 c #AE8222", "6 c #2779B4", "7 c #9B0F1B", "8 c #EECA6E", "9 c #FCF258", "0 c #F0A61F", "a c #10366C", "b c #E4891C", "c c #37A0DC", "d c #6E5E48", "e c #E1984B", "f c #D6641A", "g c #DF7F1F", "h c #F7DE72", "i c #5E3837", "j c #B6160D", "k c #F8C51E", "l c #1D6099", " ", " >66]>># ", " 44>6]c]l4%[k ", " gd.&}_1cc@>d[k* ", " 3^e[_g/1]6]2l&5k*h ", " ge0|gfd%2ccc2>450: ", " e|bbg^fg%ccc]2];0: ", "0bbbg^ge/6]66>]6~:$ ", "ebbb^^b[4]]>ll6>~h:*", "|bb^3ji&46]6l44#[$:*", "fg^^''!4>61144a;*$k8", "'^^^'{f5}^b,4aa;kkh ", " 3^^ff3{{(-...d[k:h ", " '^^^^f3+....i^kk98 ", " 7{^^^^^f(ii!^^|99 ", " j'fff^^^g^gf^$$[ ", " jj''{ffff^g*$[ ", " jjjjjj{{fg|g ", " <7jjj''{} ", " === "}; bitmaps/Hline.xpm [[[1 30 /* XPM */ static char *Hline[] = { /* width height num_colors chars_per_pixel */ " 20 20 4 1", /* colors */ ". c #333366", "# c #6666cc", "a c None", "b c #ffffff", /* pixels */ "aaaaaaaaaaaaaaaaaaaa", "aaaaaaaaaaaaaaaaaaaa", "aaaaaaaaaaaaaaaaaaaa", "aaaaaaaaaaaaaaaaaaaa", "aaaaaaaaaaaaaaaaaaaa", "aaaaaaaaaaaaaaaaaaaa", "aaaaaaaaaaaaaaaaaaaa", "aaaaaaaaaaaaaaaaaaaa", "aaaaaaaaaaaaaaaaaaaa", "a.................#a", "a##################a", "abbbbbbbbbbbbbbbbb#a", "aaaaaaaaaaaaaaaaaaaa", "aaaaaaaaaaaaaaaaaaaa", "aaaaaaaaaaaaaaaaaaaa", "aaaaaaaaaaaaaaaaaaaa", "aaaaaaaaaaaaaaaaaaaa", "aaaaaaaaaaaaaaaaaaaa", "aaaaaaaaaaaaaaaaaaaa", "aaaaaaaaaaaaaaaaaaaa"}; bitmaps/IE.xpm [[[1 95 /* XPM */ static char * IE_xpm[] = { "20 20 72 1", " c None", ". c #000000", "+ c #808000", "@ c #000080", "# c #008080", "$ c #C0C0C0", "% c #C0DCC0", "& c #161616", "* c #222222", "= c #292929", "- c #555555", "; c #4D4D4D", "> c #393939", ", c #EFD6C6", "' c #E7E7D6", ") c #ADA990", "! c #000033", "~ c #333333", "{ c #666633", "] c #999933", "^ c #000066", "/ c #003366", "( c #333366", "_ c #336666", ": c #666666", "< c #999966", "[ c #CC9966", "} c #99CC66", "| c #CCCC66", "1 c #FFCC66", "2 c #000099", "3 c #333399", "4 c #006699", "5 c #336699", "6 c #669999", "7 c #CC9999", "8 c #99CC99", "9 c #CCCC99", "0 c #FFCC99", "a c #FFFF99", "b c #003399", "c c #3333CC", "d c #0066CC", "e c #3366CC", "f c #666699", "g c #0099CC", "h c #3399CC", "i c #6699CC", "j c #99CCCC", "k c #FFFFCC", "l c #0033CC", "m c #0066FF", "n c #3366FF", "o c #6666CC", "p c #0099FF", "q c #3399FF", "r c #00CCFF", "s c #33CCFF", "t c #66CCFF", "u c #33FFFF", "v c #99FFFF", "w c #CCFFFF", "x c #66FFFF", "y c #5F5F5F", "z c #777777", "A c #969696", "B c #B2B2B2", "C c #A0A0A4", "D c #808080", "E c #FFFF00", "F c #0000FF", "G c #FFFFFF", " ", " ", " FFFF ", " FFFFFF F ", " @FFFFFFF@ F ", " @FFEFFFFFF@ ", " @@+EFF@@FFFF@ ", " @+EFFF .FFF@ ", " @+EFFF .FFF@ ", " +EFFFFFFFFFFFF@ ", " +E+FFFF@@@@@@@@@ ", " + F@FFF ", " ++F@FFF .FFF@ ", " +FF@@FFFDD.FFFF@ ", " +F .@@FFFFFFFF@ ", " +F ..@@FFFF@@ ", " FF F...... ", " FFF ", " ", " "}; bitmaps/Image.xpm [[[1 35 /* XPM */ static char *Image[] = { /* width height num_colors chars_per_pixel */ " 20 20 9 1", /* colors */ ". c #00373c", "# c #008000", "a c #333366", "b c #808000", "c c #808080", "d c None", "e c #ff6633", "f c #ff66cc", "g c #ffffff", /* pixels */ "dddddddddddddddddddd", "dddddddddddddddddddd", "dddddddddddddddddddd", "ddaaaaaaaaaaaaaaaadd", "ddaggggggggggggggadd", "ddagggggg##ggggggadd", "ddaggggg###.gggggadd", "ddaggggg.#.#gggggadd", "ddagggggg.#gggfggadd", "ddaggggggggggfcggadd", "ddaggebebgggfcfggadd", "ddaggbebeggfcfcggadd", "ddaggebebgggfcfggadd", "ddaggbebeggggfcggadd", "ddagggggggggggfggadd", "ddaggggggggggggggadd", "ddaaaaaaaaaaaaaaaadd", "dddddddddddddddddddd", "dddddddddddddddddddd", "dddddddddddddddddddd"}; bitmaps/Italic.xpm [[[1 28 /* XPM */ static char *Italic[] = { /* width height num_colors chars_per_pixel */ " 20 20 2 1", /* colors */ ". c #333366", "# c None", /* pixels */ "####################", "####################", "####################", "##############.#####", "#############..#####", "#############..#####", "############...#####", "###########.#..#####", "##########.##..#####", "##########.##..#####", "#########.###..#####", "########.####..#####", "########.......#####", "#######.#####..#####", "######.######..#####", "#####.#######..#####", "###.....###......###", "####################", "####################", "####################"}; bitmaps/Link.xpm [[[1 30 /* XPM */ static char *Link[] = { /* width height num_colors chars_per_pixel */ "20 20 4 1", /* colors */ "a c None", ". c #333366", "# c #6666cc", "b c #ffffff", /* pixels */ "aaaaaaaaaaaaaaaaaaaa", "aaaaaaaaaaaaaaaaaaaa", "aaaaaaaaaaaaaaaaaaaa", "aaaaaaaaaaaaaa..aaaa", "aaaaaaaaaaaaa.ab.aaa", "aaaaaaaaa....ab#.aaa", "aaaaaaaa.ab.ab#.aaaa", "aaaaaaa.ab.ab#.aaaaa", "aaaaaa.ab..##..aaaaa", "aaaaa.ab.aa..a.aaaaa", "aaaa.ab.aab.ab.aaaaa", "aaaa.b..ab.ab.aaaaaa", "aaaa..aa..ab.aaaaaaa", "aaaa.ab#.ab.aaaaaaaa", "aaa.ab#.ab.aaaaaaaaa", "aaa.b#....aaaaaaaaaa", "aaa...aaaaaaaaaaaaaa", "aaaaaaaaaaaaaaaaaaaa", "aaaaaaaaaaaaaaaaaaaa", "aaaaaaaaaaaaaaaaaaaa"}; bitmaps/Litem.xpm [[[1 25 /* XPM */ static char * ListItem_xpm[] = { "20 20 2 1", " c None", ". c #000000", " ", " ", " ", " ", " ", " ", " ", " . ", " ... ", " ..... ......... ", " ... ......... ", " . ", " ", " ", " ", " ", " ", " ", " ", " "}; bitmaps/Lynx.xpm [[[1 46 /* XPM */ static char * Lynx_xpm[] = { "22 19 24 1", " c None", ". c #000000", "+ c #ADADAD", "@ c #D6D6D6", "# c #EAEAEA", "$ c #999999", "% c #FFFFFF", "& c #666666", "* c #707070", "= c #C1C1C1", "- c #CCCCCC", "; c #A3A3A3", "> c #515151", ", c #7A7A7A", "' c #5B5B5B", ") c #E0E0E0", "! c #F4F4F4", "~ c #B7B7B7", "{ c #3D3D3D", "] c #333333", "^ c #848484", "/ c #141414", "( c #282828", "_ c #8E8E8E", " . ", " + ", " .+. ", " .. .@. ", " .#. .$@. ", " .%&.. *$*.&=%- ", " .-;>,....%'$>)#. ", " .-!,~-{~%%%#;)#. ", " .#]%#+%%%%%%%). ", " .%#@=%%=$@%%%~. ", " .%#'=%%%#&;!),.& ", " .+#^#%%%*/,({{., ..", " .#{,@%@=%#*=%%.. ", ".. *.@)!%@#%%#%%%%. ..", " ..'$%@*+%@#+^$_. * ", ".. .^=%%@$$*%#$+. ", " ({.!##%%%... ", " _..%%.. ", " .. "}; bitmaps/Mozilla.xpm [[[1 26 /* XPM */ static char * Mozilla_xpm[] = { "20 20 3 1", " c None", ". c #000000", "+ c #FF0000", " ", " ", " .... ... ", " ..++++..... ", " ..++..+..+.. ", " ...++.+.++.... ", " ....+++..++++++.. ", " ..++++++++.+++++..", "....++.++++...++++..", " ..++..+++.....+++.", " ...+++.++++++......", " ...+++...+..+++.. ", " ...+++++... ... ", " ..+++++.. ", " ..++++.. ", " ..+++.. ", " .... ", " ", " ", " "}; bitmaps/Netscape.xpm [[[1 35 /* XPM */ static char *netscape[] = { /* width height num_colors chars_per_pixel */ " 20 20 9 1", /* colors */ ". c #ffff00", "# c #c0c0c0", "a c #c00000", "b c #a0a0a4", "c c #808080", "d c #800000", "e c None", "f c #0000c0", "g c #000000", /* pixels */ "eeeeeeeeeeeeeeeeeeee", "eeeeeeeeeeeeeeeeeeee", "eefffffffgfffffffgee", "eeffggfff#fffggfgeee", "eeff#dggg#gggd#geeee", "eefff#b..#..b#geeeee", "eefff#.ag#ga#geeeeee", "eeffb#a#g#g#a#ceeeee", "eeff#dgf###gedceeeee", "ee##...##.#####ccgee", "eegg#gda###adg#gggee", "eeff.gf#g#gceg.eeeee", "eeffd##gg#gec#deeeee", "eefff.bgd#dgbceeeeee", "eeff#ba.###.abceeeee", "eef#bgegc#cgegbceeee", "eefgceeed#deeeggeeee", "eegeeeeeegeeeeeeeeee", "eeeeeeeeeeeeeeeeeeee", "eeeeeeeeeeeeeeeeeeee"}; bitmaps/Nlist.xpm [[[1 28 /* XPM */ static char *Nlist[] = { /* width height num_colors chars_per_pixel */ " 20 20 2 1", /* colors */ ". c #000000", "# c None", /* pixels */ "####################", "####################", "###.################", "##..################", "###.#####.........##", "##...#.#############", "####################", "####################", "##..################", "####.###############", "###.#####.........##", "##...#.#############", "####################", "####################", "##...###############", "###.################", "####.####.........##", "##..##.#############", "####################", "####################"}; bitmaps/Opera.xpm [[[1 28 /* XPM */ static char * Opera_xpm[] = { "20 20 5 1", " c None", ". c #000000", "+ c #FF0000", "@ c #7F7F7F", "# c #999999", " ", " ", " ", " .... ", " .++++. ", " .+. .+. ", " .++. .++. ", " .+. .+. ", " @#@@@@.++. .++.", " @@@ @.++.# .++.", "@@@@ .++.#@ .++.", "@@@@@ .++.@@@#.++.", " #@@@@ .++.#@@#.++.", " @#@@@@ .++.@@@@.++.", " @@@@@@ .+. #@.+. ", " #@#@@@.++. #.++. ", " @@@@@.+. .+. ", " @@#@.++++. ", " @@.... ", " "}; bitmaps/Paragraph.xpm [[[1 25 /* XPM */ static char * Paragraph_xpm[] = { "20 20 2 1", " c None", ". c #000000", " ", " ", " ", " ....... ", " ... . ", " .... . ", " .... . ", " .... . ", " ... . ", " .. . ", " . . ", " . . ", " . . ", " . . ", " . . ", " . . ", " . . ", " ", " ", " "}; bitmaps/Preview.xpm [[[1 28 /* XPM */ static char * Preview_xpm[] = { "24 20 5 1", " c None", ". c #000000", "+ c #7B7B7B", "@ c #BDBDBD", "# c #FFFFFF", " ", " ", " ....... ", " ........... ", " ............. ", " .........+++... ", " ......###..@@+... ", " .......###...@@++.. ", " ...........#...#@@+.. ", "............#...@#@@+.. ", "............#...#@#@+...", "....#.......#...@#@@+.. ", " ...#......#....#@@+.. ", " ...#....#....@@@+.. ", " ...####....@@@+.. ", " .........@@++.. ", " .......+++... ", " .......... ", " ", " "}; bitmaps/Table.xpm [[[1 31 /* XPM */ static char *Table[] = { /* width height num_colors chars_per_pixel */ " 20 20 5 1", /* colors */ "- c None", ". c #333366", "# c #9999ff", "a c #c0c0c0", "b c #ffffff", /* pixels */ "--------------------", "--------------------", "--------------------", "--bbbbbbbbbbbbbbb.--", "--baaaaaaaaaaaaaa.--", "--ba...a...a...aa.--", "--ba.#ba.#ba.#baa.--", "--ba.#ba.#ba.#baa.--", "--ba.#ba.#ba.#baa.--", "--babbbabbbabbbaa.--", "--baaaaaaaaaaaaaa.--", "--ba...a...a...aa.--", "--ba.#ba.#ba.#baa.--", "--ba.#ba.#ba.#baa.--", "--ba.#ba.#ba.#baa.--", "--babbbabbbabbbaa.--", "--baaaaaaaaaaaaaa.--", "--................--", "--------------------", "--------------------"}; bitmaps/Target.xpm [[[1 29 /* XPM */ static char *Target[] = { /* width height num_colors chars_per_pixel */ " 20 20 3 1", /* colors */ ". c #000080", "a c None", "b c #ff0000", /* pixels */ "aaaaaaaaaaaaaaaaaaaa", "aaaaaaaaaaaaaaaaaaaa", "aaaaaaaaaaaaaaaaaaaa", "aaaaaaaaaaaaaaaaaaaa", "aaaaabaaaa...aaaaaaa", "aaaabbbaba....aaaaaa", "aaaaabbbbaaa...aaaaa", "aaaaaabbba.aa...aaaa", "aaaaabbbbaa.aa..aaaa", "aaaaaaaaa..a.a..aaaa", "aaaa..a.a..a.a..aaaa", "aaaa..aa.aa.aa..aaaa", "aaaa...aa..aa...aaaa", "aaaaa...aaaa...aaaaa", "aaaaaa........aaaaaa", "aaaaaaa......aaaaaaa", "aaaaaaaaaaaaaaaaaaaa", "aaaaaaaaaaaaaaaaaaaa", "aaaaaaaaaaaaaaaaaaaa", "aaaaaaaaaaaaaaaaaaaa"}; bitmaps/Template.xpm [[[1 34 /* XPM */ static char *Template[] = { /* width height num_colors chars_per_pixel */ " 20 20 8 1", /* colors */ ". c #6666cc", "# c #808080", "a c #9999ff", "b c None", "c c #ff0000", "d c #ff6633", "e c #ffff00", "f c #ffffff", /* pixels */ "bbbbbbbbbbbbbbbbbbbb", "bbbbbbbbbbbbbbbbbbbb", "bbebbfbfbbebbbbbbbbb", "bbbebebebebbbbbbbbbb", "bbbbeedeef......bbbb", "befeeeceeeefaf.f.bbb", "bbeddcecd#bafa.ff.bb", "beffeeceeeefaf....bb", "bbbbeedeebfafafaf.bb", "bbbebe.eaeafafafa.bb", "bbfbbf.afafafafaf.bb", "bbbbbe.eafafafafa.bb", "bbbbbb.afafafafaf.bb", "bbbbbb.fafafafafa.bb", "bbbbbb.afafafafaf.bb", "bbbbbb.fafafafafa.bb", "bbbbbb.afafafafaf.bb", "bbbbbb............bb", "bbbbbbbbbbbbbbbbbbbb", "bbbbbbbbbbbbbbbbbbbb"}; bitmaps/Underline.xpm [[[1 29 /* XPM */ static char *Underline[] = { /* width height num_colors chars_per_pixel */ " 20 20 3 1", /* colors */ ". c #222222", "# c #333366", "a c None", /* pixels */ "aaaaaaaaaaaaaaaaaaaa", "aaaaaaaaaaaaaaaaaaaa", "aaaaaaaaaa#aaaaaaaaa", "aaaaaaaaa###aaaaaaaa", "aaaaaaaaa###aaaaaaaa", "aaaaaaaa#####aaaaaaa", "aaaaaaaa#a###aaaaaaa", "aaaaaaa##aa###aaaaaa", "aaaaaaa#aaa###aaaaaa", "aaaaaa##aaaa###aaaaa", "aaaaaa#aaaaa###aaaaa", "aaaaa###########aaaa", "aaaaa#aaaaaaa###aaaa", "aaaa##aaaaaaaa###aaa", "aaa###aaaaaaaa####aa", "aa#####aaaaa#######a", "aaaaaaaaaaaaaaaaaaaa", "aa.................a", "aaaaaaaaaaaaaaaaaaaa", "aaaaaaaaaaaaaaaaaaaa"}; bitmaps/w3m.xpm [[[1 33 /* XPM */ static char * W3m_xpm[] = { "20 20 10 1", " c None", ". c #FF0000", "+ c #00FF00", "@ c #679900", "# c #FB0400", "$ c #0300FC", "% c #0600F9", "& c #0000FF", "* c #009F60", "= c #0005FA", " . ", " .. ", " ... .. ", " .. .... ", " ....... ", " ++++ ....... .. ", " ++++++@#.. ...... ", " ++++ . ..... ", " ++++++ .... ", " ++++ .. ", " +++++ $% ", " ++++++ &&&& ", " ++++ & &&&&& ", " ++++++*=&& &&&&&& ", " ++++ &&&&&& &&& ", " &&&&&&& ", " && &&&& ", " && && ", " && ", " & "}; browser_launcher.vim [[[1 346 "-------------------------------------------------------------------------- " " Vim script to launch/control browsers " " Copyright ????-2008 Christian J. Robinson " " Distributable under the terms of the GNU GPL. " " Currently supported browsers: " - Firefox (remote [new window / new tab] / launch) [1] " - Mozilla (remote [new window / new tab] / launch) [1] " - Netscape (remote [new window] / launch) [1] " - Opera (remote [new window / new tab] / launch) " - Lynx (Under the current TTY if not running the GUI, or a new xterm " window if DISPLAY is set.) " - w3m (Under the current TTY if not running the GUI, or a new xterm " window if DISPLAY is set.) " " TODO: " " Support more browsers? " - links (text browser) " " Defaulting to lynx if the the GUI isn't available may be undesirable. " " Note: Various browsers such as galeon, nautilus, phoenix, &c use the " same HTML rendering engine as mozilla/firefox, so supporting them " isn't as important. " " BUGS: " * [1] The remote control for firefox/mozilla/netscape will probably " default to firefox if more than one is running. " " * Since the commands to start the browsers are run in the backgorund " there's no way to actually get v:shell_error, so execution errors " aren't actually seen when not issuing a command to an already running " browser. " " * The code is a mess. Oh well. " "-------------------------------------------------------------------------- if v:version < 700 finish endif command! -nargs=+ BERROR :echohl ErrorMsg | echomsg | echohl None command! -nargs=+ BMESG :echohl Todo | echo | echohl None " Attempt to detect which browsers are installed: {{{1 if has('unix') let s:Browsers = {} let s:BrowsersExist = 'fmnolw' let s:Browsers['f'] = ['firefox', 0] let s:Browsers['m'] = ['mozilla', 0] let s:Browsers['n'] = ['netscape', 0] let s:Browsers['o'] = ['opera', 0] let s:Browsers['l'] = ['lynx', 0] let s:Browsers['w'] = ['w3m', 0] for s:temp1 in keys(s:Browsers) let s:temp2 = system("which " . s:Browsers[s:temp1][0]) if v:shell_error == 0 let s:Browsers[s:temp1][1] = substitute(s:temp2, "\n$", '', '') else let s:BrowsersExist = substitute(s:BrowsersExist, s:temp1, '', 'g') endif endfor unlet s:temp1 s:temp2 let s:NetscapeRemoteCmd = substitute(system("which mozilla-xremote-client"), "\n$", '', '') if v:shell_error != 0 let s:NetscapeRemoteCmd = substitute(system("which netscape-remote"), "\n$", '', '') endif if v:shell_error != 0 if s:Browsers['f'][1] != 0 let s:NetscapeRemoteCmd = s:Browsers['f'][1] elseif s:Browsers['m'][1] != 0 let s:NetscapeRemoteCmd = s:Browsers['m'][1] elseif s:Browsers['n'][1] != 0 let s:NetscapeRemoteCmd = s:Browsers['n'][1] else "BERROR Can't set up remote-control preview code. "BERROR (netscape-remote/firefox/mozilla/netscape not installed?) "finish let s:NetscapeRemoteCmd = 'false' endif endif elseif has('win32') || has('win64') BERROR Currently there's no browser control support for Windows. BERROR See ":help html-author-notes" "let s:Browsers = {} "let s:BrowsersExist = '' "if filereadable('C:\Program Files\Mozilla Firefox\firefox.exe') " let s:Browsers['f'] = ['firefox', '"C:\Program Files\Mozilla Firefox\firefox.exe"'] " let s:BrowsersExist .= 'f' "endif "if s:Browsers['f'][1] != '' " let s:NetscapeRemoteCmd = s:Browsers['f'][1] "endif elseif has('mac') || has('macunix') BERROR Currently there's no browser control support for Macintosh. BERROR See ":help html-author-notes" endif " }}}1 if exists("*LaunchBrowser") finish endif function! s:ShellEscape(str) if exists('*shellescape') return shellescape(a:str) else return "'" . substitute(a:str, "'", "'\\\\''", 'g') . "'" endif endfunction " LaunchBrowser() {{{1 " " Usage: " :call LaunchBrowser({[nolmf]},{[012]},[url]) " The first argument is which browser to launch: " f - Firefox " m - Mozilla " n - Netscape " o - Opera " l - Lynx " w - w3m " " default - This launches the first browser that was actually found. " " The second argument is whether to launch a new window: " 0 - No " 1 - Yes " 2 - New Tab (or new window if the browser doesn't provide a way to " open a new tab) " " The optional third argument is an URL to go to instead of loading the " current file. " " Return value: " 0 - Failure (No browser was launched/controlled.) " 1 - Success " " A special case of no arguments returns a character list of what browsers " were found. function! LaunchBrowser(...) let err = 0 if a:0 == 0 return s:BrowsersExist elseif a:0 >= 2 let which = a:1 let new = a:2 else let err = 1 endif let file = 'file://' . expand('%:p') if a:0 == 3 let file = a:3 elseif a:0 > 3 let err = 1 endif if err exe 'BERROR E119: Wrong number of arguments for function: ' \ . substitute(expand(''), '^function ', '', '') return 0 endif if which ==? 'default' let which = strpart(s:BrowsersExist, 0, 1) endif if s:BrowsersExist !~? which if exists('s:Browsers[which]') exe 'BERROR ' . s:Browsers[which][0] . ' not found' else exe 'BERROR Unknown browser ID: ' . which endif return 0 endif if has('unix') && (! strlen($DISPLAY) || which ==? 'l') " {{{ BMESG Launching lynx... if (has("gui_running") || new) && strlen($DISPLAY) let command='xterm -T Lynx -e lynx ' . s:ShellEscape(file) . ' &' else sleep 1 execute "!lynx " . s:ShellEscape(file) if v:shell_error BERROR Unable to launch lynx. return 0 endif endif endif " }}} if (which ==? 'w') " {{{ BMESG Launching w3m... if (has("gui_running") || new) && strlen($DISPLAY) let command='xterm -T w3m -e w3m ' . s:ShellEscape(file) . ' &' else sleep 1 execute "!w3m " . s:ShellEscape(file) if v:shell_error BERROR Unable to launch w3m. return 0 endif endif endif " }}} if (which ==? 'o') " {{{ if new == 2 BMESG Opening new Opera tab... let command="sh -c \"trap '' HUP; " . s:Browsers[which][1] . " -remote 'openURL('" . s:ShellEscape(file) . "',new-page)' &\"" elseif new BMESG Opening new Opera window... let command="sh -c \"trap '' HUP; " . s:Browsers[which][1] . " -remote 'openURL('" . s:ShellEscape(file) . "',new-window)' &\"" else BMESG Sending remote command to Opera... let command="sh -c \"trap '' HUP; " . s:Browsers[which][1] . " " . s:ShellEscape(file) . " &\"" endif endif " }}} " Find running instances firefox/mozilla/netscape: {{{ if has('unix') let FirefoxRunning = 0 let MozillaRunning = 0 let NetscapeRunning = 0 let windows = system("xwininfo -root -children | egrep \"[Ff]irefox|[Nn]etscape|[Mm]ozilla\"; return 0") if windows =~? 'firefox' let FirefoxRunning = 1 endif if windows =~? 'mozilla' let MozillaRunning = 1 endif if windows =~? 'netscape' let NetscapeRunning = 1 endif else " ... Make some assumptions: "let FirefoxRunning = 1 endif " }}} if (which ==? 'f') " {{{ if ! FirefoxRunning BMESG Launching firefox, please wait... let command="sh -c \"trap '' HUP; " . s:Browsers[which][1] . " " . s:ShellEscape(file) . " &\"" else if new == 2 BMESG Opening new Firefox tab... let command=s:NetscapeRemoteCmd . " -remote 'openURL('" . s:ShellEscape(file) . "',new-tab)'" elseif new BMESG Opening new Firefox window... let command=s:NetscapeRemoteCmd . " -remote 'openURL('" . s:ShellEscape(file) . "',new-window)'" else BMESG Sending remote command to Firefox... let command=s:NetscapeRemoteCmd . " -remote 'openURL('" . s:ShellEscape(file) . "')'" endif endif endif " }}} if (which ==? 'm') " {{{ if ! MozillaRunning BMESG Launching mozilla, please wait... let command="sh -c \"trap '' HUP; " . s:Browsers[which][1] . " " . s:ShellEscape(file) . " &\"" else if new == 2 BMESG Opening new Mozilla tab... let command=s:NetscapeRemoteCmd . " -remote 'openURL('" . s:ShellEscape(file) . "',new-tab)'" elseif new BMESG Opening new Mozilla window... let command=s:NetscapeRemoteCmd . " -remote 'openURL('" . s:ShellEscape(file) . "',new-window)'" else BMESG Sending remote command to Mozilla... let command=s:NetscapeRemoteCmd . " -remote 'openURL('" . s:ShellEscape(file) . "')'" endif endif endif " }}} if (which ==? 'n') " {{{ if ! NetscapeRunning BMESG Launching netscape, please wait... let command="sh -c \"trap '' HUP; " . s:Browsers[which][1] . " " . s:ShellEscape(file) . " &\"" else if new BMESG Opening new Netscape window... let command=s:NetscapeRemoteCmd . " -remote 'openURL('" . s:ShellEscape(file) . "',new-window)'" else BMESG Sending remote command to Netscape... let command=s:NetscapeRemoteCmd . " -remote 'openURL('" . s:ShellEscape(file) . "')'" endif endif endif " }}} if exists('l:command') if command =~ 'mozilla-xremote-client' let command = substitute(command, '-remote', '-a ' . s:Browsers[which][0], '') endif if ! has('unix') let command = substitute(command, "sh -c \"trap '' HUP; \\(.\\+\\) &\"", '\1', '') let command = substitute(command, '"\(openURL(.\+)\)"', '\1', '') endif call system(command) if has('unix') && v:shell_error exe 'BERROR Command failed: ' . command return 0 endif return 1 endif " Should never get here...if we do, something went wrong: BERROR Something went wrong, shouln't ever get here... return 0 endfunction " }}}1 " vim: set ts=2 sw=2 ai nu tw=75 fo=croq2 fdm=marker fdc=3: doc/HTML.txt [[[1 1042 *HTML.txt* Set of HTML/XHTML macros, menus and toolbar buttons. Last change: 2008 Jun 18 Author: Christian J. Robinson *HTML.vim* *HTML-macros* *XHTML-macros* This is a set of HTML/XHTML macros, menus, and toolbar buttons to make editing HTML files easier. The original Copyright goes to Doug Renze, although nearly all of his efforts have been modified in this implementation. All the changes are Copyright Christian J. Robinson. These macros and the supporting scripts are distributable under the terms of the GNU GPL version 2 or later. ------------------------------------------------------------------------------ 1. Introduction |html-intro| 2. Customization Variables |html-variables| 3. Commands |html-commands| 4. Mappings for Normal <> Tags |html-tags| 5. Mappings for &...; Codes, such as < > & and so on |character-codes| 6. How to Use Browser Mappings |browser-control| 7. Miscellaneous Extras |html-misc| ============================================================================== 1. Introduction *html-intro* To start, you should familiarize yourself with Vim enough to know the terminology, and you should know HTML to some degree. The mappings are local to the buffer the script was sourced from, and the menu and toolbar are active only for buffers the script was sourced from. This help file follows the Vim help file standards. To see what modes a mapping works in see the tags between the **'s. For example, the |;;| mapping below works in normal, insert mode and visual mode. In the descriptions of the mappings I often use to mean a literal newline. *html-smart-tag* Noted tags are "smart"--if syntax highlighting is enabled it can be used to detect whether to close then open a tag instead of open then close the tag. For example, if the cursor is in italicized text and you type ;it, it will insert instead of . This can not be done on most tags due to its dependence on the syntax highlighting. NOTE: Some tags are synonyms and Vim can't distinguish between them. For example, if you're within and type |;em| it will assume you want rather than , which you should not be doing anyway. *n_;;* *i_;;* *v_;;* ;; Most of the mappings start with ; so ;; is mapped to insert a single ; character in insert mode, behave like a single ; in normal mode, etc. (The semicolons in this mapping are changed to whatever |g:html_map_leader| is set to.) *i_;&* ;& The HTML |character-entities| insert mode mappings start with &, so typing ;& in insert mode will insert a literal & character. (In actuality this mapping is defined as |g:html_map_leader| + |g:html_map_entity_leader| to insert whatever is in |g:html_map_entity_leader|.) (See also |n_;&|) *html-* *html-tab* *html-CTRL-I* *i_html-* *i_html-tab* *i_html-CTRL-I* *v_html-* *v_html-tab* *v_html-CTRL-I* If the cursor is on a closing tag the tab key jumps the cursor after the tag. Otherwise the tab key will jump the cursor to an unfilled tag somewhere in the file. For example, if you had the tag: > < And you hit tab, your cursor would be placed on the second " so you could insert text easily. Next time you hit tab it would be placed on the < character of . And the third time you hit tab the cursor would be placed on the > of , and so on. This works for tags split across lines, such as: >
< Currently using this mapping in visual mode clears the visual selection. See |g:no_html_tab_mapping| if you do not want these mappings to be defined, in which case ; will be used for the mappings instead. [I think the use of tab is acceptable because I do not like the idea of hard tabs or indentation greater than one or two spaces in HTML.] *i_;* *i_;tab* *i_;CTRL-I* *n_;* *n_;tab* *n_;CTRL-I* ; To insert a hard tab (; then the tab key). If |g:no_html_tab_mapping| is set this mapping replaces the normal |html-tab| mapping instead. (See |g:html_map_leader|) *n_;html* ;html This macro inserts a basic template at the top of the file. If the buffer already contains some text you are asked if you want to replace it or add the template anyway. (See |g:html_map_leader|) See |g:html_template| for information on how to customize the template. *disable-HTML-macros* *HTML-macros-disable* *HTML-disable-macros* *disable-HTML-mappings* *HTML-mappings-disable* *HTML-disable-mappings* *:HTMLmappings* :HTML[mappings] {disable/off/enable/on} This command allows the HTML macros to be disabled and re-enabled. This is useful for editing inline PHP, JavaScript, etc. where you would want to be able to type literal ";", "&" and tab characters without interference. (Also see |;;|, |;&| and |;|) Note that all of the mappings defined by calling |HTMLmap()| or |HTMLmapo()|--including all of the mappings defined by this script--are disabled/enabled when this command is used, regardless of what |g:html_map_leader| is set to. ============================================================================== 2. Customization Variables *html-variables* *html-configuration* *html-customization* You can set the following global Vim variables to control the behavior of the macros. It is recommended you set these variables in your .vimrc--some of them are only effective if they are set before HTML.vim is sourced. Note that "nonzero" means anything besides "no", "false", 0, or "" (empty value)--case insensitive. *g:do_xhtml_mappings* *b:do_xhtml_mappings* Set this variable to a nonzero value if you prefer XHTML compatible tags to be defined. Setting this forces |b:html_tag_case| to "lowercase". This is automatic if you are already editing a file that Vim detects as XHTML. This variable must be set before HTML.vim is sourced for the current buffer. You can also set this on a per-buffer basis by using b:do_xhtml_mappings instead. e.g.: > :let g:do_xhtml_mappings = 'yes' *g:html_tag_case* *b:html_tag_case* This variable can be set to "l" / "lower" / "lowercase" or "u" / "upper" / "uppercase" to determine the case of the text in the HTML tags. This variable must be set before HTML.vim is sourced for the current buffer. The default is "uppercase". You can also set this on a per-buffer basis by using b:html_tag_case instead. This variable is ignored when editing XHTML files (see |g:do_xhtml_mappings|). e.g: > :let g:html_tag_case = 'lowercase' *g:html_tag_case_autodetect* Set this variable to a nonzero value if you want to automatically detect what the value of |b:html_tag_case| should be. This is done by examining the file for both upper and lower case tags (tag attributes are not examined). If only one type is found the tag case for the buffer is set to that value. This variable is ignored if you have set |g:do_xhtml_mappings|. e.g.: > :let g:html_tag_case_autodetect = 'yes' *g:html_map_leader* This variable can be set to the character you want for the leader of the mappings defined under |html-tags|, the default being ';'. This variable must be set before HTML.vim is sourced. You can set this to your |mapleader| or |maplocalleader|. e.g.: > :let g:html_map_leader = g:maplocalleader *g:html_map_entity_leader* This variable can be set to the character you want for the leader of the character entity insert mode mappings defined under |character-entities|, the default being '&'. This variable must be set before HTML.vim is sourced. If you attempt to set this to the same value as |g:html_map_leader| you will get an error. e.g.: > :let g:html_map_entity_leader = '\' *g:no_html_map_override* Set this variable to a nonzero value if you do not want this plugin to override mappings that already exist. When this variable is not set you will get a warning message when this plugin overrides a mapping. This variable must be set before HTML.vim is sourced. e.g.: > :let g:no_html_map_override = 'yes' This only applies to the mappings defined internally to the plugin. If you call the |HTMLmap()| function elsewhere you will still get a warning message when there's an already existing mapping and the mapping will still be overridden. *g:no_html_maps* *b:no_html_maps* Set this variable a regular expression to match against mappings. If a mapping to be defined matches this regular expression it will not be defined. You can also set this on a per-buffer basis by using b:no_html_maps instead. The patterns are case sensitive, will not undergo |g:html_map_leader| and |g:html_map_entity_leader| substitution, and must be set before HTML.vim is sourced. e.g., to suppress the , and the centered headers tags: > :let g:no_html_maps = '^\(;ah\|;im\|;H\d\)$' This only applies to the mappings defined internally to the plugin. If you call the |HTMLmap()| function elsewhere the mapping will be defined even if it matches this regular expression. This is useful if you wish to define custom variants of some of the plugin's mappings without getting warning messages. *g:no_html_tab_mapping* Set this variable to a nonzero value if you do not want the tab key to be mapped in normal, visual and insert mode. ; will be used instead. See |html-tab| and |i_;tab|. This variable must be set before HTML.vim is sourced for the current buffer. e.g.: > :let g:no_html_tab_mapping = 'yes' Note that you can suppress the defining of both and ; as a mapping by adding "\t" to |g:no_html_maps| instead. *g:no_html_toolbar* Set this variable to a nonzero value if you do not want this plugin to modify the Vim toolbar and add "T" to 'guioptions'. This variable must be set before HTML.vim is sourced. e.g.: > :let g:no_html_toolbar = 'yes' *g:no_html_menu* Set this variable to a nonzero value if you don't want the menu items to be defined at all. This implies that |g:no_html_toolbar| is set as well. This variable must be set before HTML.vim is sourced. e.g.: > :let g:no_html_menu = 'yes' *g:force_html_menu* Set this variable to a nonzero value if you want the menu items to be defined even if you're not in the GUI. This is useful if you want to use the menus in the console (see |console-menus|). This variable is ignored if |g:no_html_menu| is set. This variable must be set before HTML.vim is sourced. e.g.: > :let g:force_html_menu = 'yes' *g:html_template* *b:html_template* Set this variable to the location of your template file to be used by the |;html| mapping. You can also set this on a per-buffer basis by using b:html_template instead. If unset, a basic internal template will be used. See |html-template-tokens| for special tokens you can use within the template. *g:html_authorname* *g:html_authoremail* Within the internal template, html_authorname is inserted inside g:html_authoremail is converted to |g:html_authoremail_encoded| and inserted inside e.g.: > :let g:html_authorname = 'John Smith' :let g:html_authoremail = 'jsmith@example.com' These two variables are also used for the
section of the internal template. The default for these variables are empty strings. *g:html_authoremail_encoded* This variable will be set using |HTMLencodeString()| if your |g:html_authoremail| variable is set. (Do not set this variable yourself, it will be overwritten when the template macro is used.) *g:html_bgcolor* *g:html_textcolor* *g:html_linkcolor* *g:html_alinkcolor* *g:html_vlinkcolor* These control the tag in the internal template and can also be used as |html-tokens| in the user defined template. They default to: > :let g:html_bgcolor = '#FFFFFF' :let g:html_textcolor = '#000000' :let g:html_linkcolor = '#0000EE' :let g:html_alinkcolor = '#FF0000' :let g:html_vlinkcolor = '#990066' *g:html_default_charset* This defaults to "iso-8859-1" and is the value used if a character set can not be detected by the 'fileencoding' or 'encoding' options. See |;ct| and |html-tokens| for how this is used. (Also see |html-author-notes|) *g:html_charset* If this variable is set it completely overrides the Content-Type charset detection for the |;ct| mapping and in the |html-tokens|. Normally this should be left unset. ------------------------------------------------------------------------------ *html-template-tokens* *html-tokens* When you define a template file with the |g:html_template| variable, special tokens within the template will automatically replaced with their corresponding variable value: Token: Variable: ~ %authorname% |g:html_authorname| %authoremail% |g:html_authoremail_encoded| %bgcolor% |g:html_bgcolor| %textcolor% |g:html_textcolor| %linkcolor% |g:html_linkcolor| %alinkcolor% |g:html_alinkcolor| %vlinkcolor% |g:html_vlinkcolor| Special tokens: ~ %date% *%date%* This is replaced with the output of strftime("%B %d, %Y") (e.g.: March 16, 2004). You can send custom fields to the |strftime()| call by embedding !... (rather than %...) notation before the second "%" in the token. e.g.: > %date!m/!d/!Y !l:!M !p !Z% Would produce something like: > 03/08/2007 5:59 PM MST Note that spaces before and after the format string are ignored, and you can get literal "%" and "!" characters inside the custom format by preceding them with backslashes. e.g.: > (%date \%!r\! %) Would produce something like: > (%05:59:34 PM!) %time% or %time12% *%time%* *%time12%* This is replaced with the output of strftime("%r %Z") (e.g.: 05:59:34 PM MST) %time24% *%time24%* This is replaced with the output of strftime("%T %Z") (e.g.: 17:59:34 MST) %charset% *%charset%* This is replaced by a string that is automatically detected based on the 'fileencoding' or 'encoding' option. This can be overridden, see |g:html_default_charset| and |g:html_charset|. (Also see |html-author-notes|) %vimversion% *%vimversion%* The current version of Vim, based on |v:version|. For example, if v:version was "700" the %vimversion% token would contain "7.0". So if you had the template: > < You would get something like: > < ============================================================================== 3. Commands *html-commands* *reload-HTML-macros* *HTML-macros-reload* *HTML-reload-macros* *reload-HTML-mappings* *HTML-mappings-reload* *HTML-reload-mappings* :HTML[mappings] {reload/html/xhtml} You can also use the :HTMLmappings command to reload the entire HTML macros script, or force the HTML macros into HTML or XHTML mode. *:ColorSelect* :ColorSelect Open a window with all the colors that are defined in the HTML.Colors menu displayed and highlighted with their respective color. From this window you can slect a color to be inserted in the buffer from which the window was opened. This command fails if you're not in an HTML buffer or the colors menu wasn't defined. {only in the GUI} *n_;#* *i_;#* ;# A shortcut mapping to call |:ColorSelect|. {only in the GUI} ============================================================================== 4. Mappings for Normal <> Tags *html-tags* Most of these mappings are insert or visual mappings. In insert mode the tag is inserted and the cursor placed where you would likely want to insert text. In visual mode, the tag is wrapped around the visually selected text in a hopefully logical manner. (See |i_;ah|, |v_;aH| and |i_;ab| for explicit examples--the rest of the mappings that work in visual mode are similar.) *html-operator-mappings* *html-motion-mappings* *n_;* If you run Vim 7 or later the following noted normal mode ;-mappings take a {motion} operator. These mappings function as if you had visually highlighted the text covered by the motion and invoked the corresponding visual mapping. (There is no reasonable way to get this functionality in versions prior to Vim 7, in which case the operator mappings will not be defined.) If you are editing an XHTML file (see |g:do_xhtml_mappings|) the tags will be compatible with XHTML. Note that you can change the leader character for these mappings from ';' to another character of your preference. See |g:html_map_leader|. *n_;4* *i_;4* ;4 Inserts > < at the top of the file. If the current buffer is XHTML, it will be > < (See |g:do_xhtml_mappings|) *n_;s4* *i_;s4* ;s4 Does the same as |;4|, but the document type is strict rather than transitional. (Note that these macros are meant for a transitional document type, so be careful.) *i_;ct* ;ct Insert at the current cursor position. The actual value of the charset is automatically detected based on the 'fileencoding' or 'encoding' option. This can be overridden--see |g:html_default_charset| and |g:html_charset|. (See |html-author-notes|) *i_;cm* *v_;cm* *n_;cm* ;cm Comment tag (). (|html-smart-tag|) (|n_;|) *i_;ah* *v_;ah* *n_;ah* ;ah Anchor hyper link (
). Visual mode puts the visually selected text here and positions the cursor on the second ". (|n_;|) *i_;aH* *v_;aH* *n_;aH* ;aH Same as |;ah|, but puts the visually selected text and places the cursor on the < of . If this is used in insert mode rather than visual mode, the contents of the |clipboard| are placed between the quotes. (|n_;|) *i_;at* *v_;at* *n_;at* ;at Like |;ah| but include TARGET="" in the tag. (|n_;|) *i_;aT* *v_;aT* *n_;aT* ;aT Like |;aH| but include TARGET="" in the tag. (|n_;|) *i_;an* *v_;an* *n_;an* *i_;aN* *v_;aN* *n_;aN* ;an and ;aN Same as the |;ah| and |;aH| mappings, but uses NAME instead of HREF. (|n_;|) *i_;ab* *v_;ab* *n_;ab* ;ab Abbreviation (). Visual mode puts the visually selected text here and positions the cursor on the second ". (|n_;|) *i_;aB* *v_;aB* *n_;aB* ;aB Same as |;ab|, but puts the visually selected text and places the cursor on the < of . If this is used in insert mode rather than visual mode, the contents of the |clipboard| are placed between the quotes. (|n_;|) *i_;ac* *v_;ac* *n_;ac* *i_;aC* *v_;aC* *n_;aC* ;ac and ;aC Acronym (). Similar to the |;ab| and |;aB| mappings, but uses ACRONYM instead of ABBR. (|n_;|) *i_;ad* *v_;ad* *n_;ad* ;ad Address (
). (|n_;|) *i_;bo* *v_;bo* *n_;bo* ;bo Boldfaced Text (). (|html-smart-tag|) (|n_;|) *i_;bh* *v_;bh* *n_;bh* ;bh Base URL (). (|n_;|) *i_;bi* *v_;bi* *n_;bi* ;bi Bigger text (). (|n_;|) *i_;bl* *v_;bl* *n_;bl* ;bl Block quote (
). (|n_;|) *i_;bd* *v_;bd* *n_;bd* ;bd Body (). (|n_;|) *i_;br* ;br Line break (
). *i_;ce* *v_;ce* *n_;ce* ;ce Center (
). (|n_;|) *i_;ci* *v_;ci* *n_;ci* ;ci Cite (). (|n_;|) *i_;co* *v_;co* *n_;co* ;co Code (). (|n_;|) *html-definition-lists* *i_;dl* *v_;dl* *n_;dl* ;dl Definition list (
). (|n_;|) *i_;dt* *v_;dt* *n_;dt* ;dt Definition term (
). (|n_;|) *i_;dd* *v_;dd* *n_;dd* ;dd Definition body (
). (|n_;|) *i_;de* *v_;de* *n_;de* ;de Deleted text (). (|n_;|) *i_;df* *v_;df* *n_;df* ;df Defining instance (). (|n_;|) *i_;dv* *v_;dv* *n_;dv* ;dv Document Division (
). (|n_;|) *i_;eb* ;eb Embedded element, plus NOEMBED. ( ) *i_;ob* *v_;ob* *n_;ob* ;ob Generic embedded object (). Visual mode puts the selected text here. (|n_;|) *i_;em* *v_;em* *n_;em* ;em Emphasize (). (|html-smart-tag|) (|n_;|) *i_;fo* *v_;fo* *n_;fo* ;fo Font size (). (|n_;|) *i_;fc* *v_;fc* *n_;fc* ;fc Font color (). (|n_;|) *html-headers* *i_;h1* *v_;h1* *n_;h1* *i_;h2* *v_;h2* *n_;h2* *i_;h3* *v_;h3* *n_;h3* *i_;h4* *v_;h4* *n_;h4* *i_;h5* *v_;h5* *n_;h5* *i_;h6* *v_;h6* *n_;h6* ;h1 through ;h6 Headers, levels 1-6 (). (|n_;|) *i_;H1* *v_;H1* *n_;H1* *i_;H2* *v_;H2* *n_;H2* *i_;H3* *v_;H3* *n_;H3* *i_;H4* *v_;H4* *n_;H4* *i_;H5* *v_;H5* *n_;H5* *i_;H6* *v_;H6* *n_;H6* ;H1 through ;H6 Headers, levels 1-6, centered (). (|n_;|) *i_;he* *v_;he* *n_;he* ;he Head (). (|n_;|) *i_;hr* ;hr Horizontal rule (
). *i_;Hr* ;Hr Horizontal rule (
). *i_;ht* *v_;ht* *n_;ht* ;ht HTML document (). (|n_;|) *i_;ii* ;ii Identifies index (). *i_;it* *v_;it* *n_;it* ;it Italicized text (). (|html-smart-tag|) (|n_;|) *i_;im* *v_;im* *n_;im* ;im Image ( and places the cursor on the second " of the SRC="". (|n_;|) *i_;iM* *v_;iM* *n_;iM* ;iM Same as |;im|, but puts the visually selected text and places the cursor on the second " of ALT="". If this is used in insert mode rather than visual mode, the contents of the |clipboard| are placed between the quotes. (|n_;|) *i_;in* *v_;in* *n_;in* ;in Inserted text (). (|n_;|) *i_;js* ;js *i_;sj* ;sj *i_;ns* *v_;ns* *n_;ns* ;ns Alternate content for browsers with script handling turned off (). (|n_;|) *i_;li* *v_;li* *n_;li* ;li List item (
  • ) inside
      or
        . (|n_;|) *i_;lk* *v_;lk* *n_;lk* ;lk Link, inside the header (). (|n_;|) *i_;me* *v_;me* *n_;me* ;me Meta information ( and places the cursor on the second " of CONTENT="". (|n_;|) *i_;mE* *v_;mE* *n_;mE* ;mE Same as |;me|, but puts the visually selected text and places the cursor on the second " of NAME="". If this is used in insert mode rather than visual mode, the contents of the |clipboard| are placed between the quotes. (|n_;|) *i_;mh* *v_;mh* *n_;mh* ;mh Meta http-equiv (. (|n_;|) *n_;mi* *i_;mi* ;mi Automatically add or update the WIDTH and HEIGHT attributes of an tag. If the tag spans multiple lines the cursor must be on the first line of the tag. This mapping is only defined if MangleImageTag.vim is installed, available with installation instructions here: http://www.infynity.spodzone.com/vim/HTML/ *i_;ol* *v_;ol* *n_;ol* ;ol Ordered (numbered) list (
        ). (|n_;|) *i_;pp* *v_;pp* *n_;pp* ;pp Paragraph (

        ). (|n_;|) *i_;/p* ;/p Like above, but inserts

        . This is intended to be used when the cursor is between

        and

        in insert mode and you want to start a new paragraph without having to move the cursor. *i_;pr* *v_;pr* *n_;pr* ;pr Preformatted text (
        ). (|n_;|) *i_;qu* *v_;qu* *n_;qu* ;qu Quoted text (). (|n_;|) *i_;sk* *v_;sk* *n_;sk* ;sk Strike-through (). (|n_;|) *i_;sm* *v_;sm* *n_;sm* ;sm Small text (). (|n_;|) *i_;sn* *v_;sn* *n_;sn* ;sn Span (). (|n_;|) *i_;sa* *v_;sa* *n_;sa* ;sa Sample text (). (|n_;|) *i_;st* *v_;st* *n_;st* ;st Strong text (). (|html-smart-tag|) (|n_;|) *i_;cs* *v_;cs* *n_;cs* ;cs CSS Style (). (|n_;|) *i_;ls* *v_;ls* *n_;ls* ;ls Linked CSS style sheet (). (|n_;|) *i_;sb* *v_;sb* *n_;sb* ;sb Subscript (). (|n_;|) *i_;sp* *v_;sp* *n_;sp* ;sp Superscript (). (|n_;|) *i_;ti* *v_;ti* *n_;ti* ;ti Title (). (|n_;|) *i_;tt* *v_;tt* *n_;tt* ;tt Teletype Text (monospaced) (). (|n_;|) *i_;un* *v_;un* *n_;un* ;un Underlined text (). (|html-smart-tag|) (|n_;|) *i_;ul* *v_;ul* *n_;ul* ;ul Unordered list (
        ). (|n_;|) *html-tables* *i_;ta* *v_;ta* *n_;ta* ;ta Table (
        ). (|n_;|) *n_;tA* ;tA Interactive table; you will be interactively prompted for the table rows, columns, and border width. *i_;tH* *v_;tH* *n_;tH* ;tH Table header row (). (|n_;|) *i_;tb* *v_;tb* *n_;tb* ;tb Table body (). (|n_;|) *i_;tf* *v_;tf* *n_;tf* ;tf Table footer row (). (|n_;|) *i_;ca* *v_;ca* *n_;ca* ;ca Table caption (). (|n_;|) *i_;tr* *v_;tr* *n_;tr* ;tr Table row (). (|n_;|) *i_;td* *v_;td* *n_;td* ;td Table data (column element) (). (|n_;|) *i_;th* *v_;th* *n_;th* ;th Table column header (). (|n_;|) *html-frames* *i_;fs* *v_;fs* *n_;fs* ;fs Frame layout (). (|n_;|) *i_;fr* *v_;fr* *n_;fr* ;fr Frame source (). (|n_;|) *i_;nf* *v_;nf* *n_;nf* ;nf Text to display if for a browser that can not display frames (<CR>). (|n_;|) *i_;if* *v_;if* *n_;if* ;if Inline frame (). (|n_;|) *html-forms* *i_;fm* *v_;fm* *n_;fm* ;fm Form (
        ). (|n_;|) *i_;bu* *v_;bu* *n_;bu* ;bu Form button (). Visual mode puts the selected text VALUE="here". (|n_;|) *i_;ch* *v_;ch* *n_;ch* ;ch Form check box (). Visual mode puts the selected text VALUE="here". (|n_;|) *i_;ra* *v_;ra* *n_;ra* ;ra Form radio button (). Visual mode puts the selected text VALUE="here". (|n_;|) *i_;hi* *v_;hi* *n_;hi* ;hi Hidden form data (). Visual mode puts the selected text VALUE="here". (|n_;|) *i_;pa* *v_;pa* *n_;pa* ;pa Form password input field (). Visual mode puts the selected text VALUE="here". (|n_;|) *i_;te* *v_;te* *n_;te* ;te Form text input field (). Visual mode puts the selected text VALUE="here". (|n_;|) *i_;fi* *v_;fi* *n_;fi* ;fi Form file input field (). Visual mode puts the selected text VALUE="here". (|n_;|) *i_;se* *v_;se* *n_;se* ;se Form selection box (). Visual mode puts the selected text . (|n_;|) *i_;ms* *v_;ms* *n_;ms* ;ms Form multiple selection box (). Visual mode puts the selected text . (|n_;|) *i_;op* *v_;op* *n_;op* ;op Form selection option (). (|n_;|) *i_;og* *v_;og* *n_;og* ;og Form option group (). Visual mode puts the selected text here. (|n_;|) *i_;tx* *v_;tx* *n_;tx* ;tx Form text input area (). Visual mode puts the selected text . (|n_;|) *i_;su* ;su Form submit button (). *i_;re* ;re Form reset button (). *i_;la* *v_;la* *n_;la* ;la Form element label (). Visual mode puts the visually selected text and positions the cursor on the second ". (|n_;|) *v_;lA* *n_;lA* ;lA The same as |;la| but puts the cursor and places the cursor on the < of . (|n_;|) ============================================================================== 5. Mappings for &...; Codes *character-codes* *character-entities* A number of mappings have been defined to allow insertion of special characters into the HTML buffer. These are known as characters entities. *n_;&* *v_;&* ;& This mapping converts the motion or visually selected characters to their &#...; entities, where "..." is equivalent to the ASCII decimal representation. For example, "foo bar" would become "foo bar". (See |i_;&|) (|n_;|) (Note that the "&" in this mapping is not translated to whatever |g:html_map_entity_leader| is set to.) *n_;%* *v_;%* ;% This mapping converts the motion or visually selected characters to their %XX hexadecimal string for URIs. For example, "foo bar" would become "%66%6F%6F%20%62%61%72". (|n_;|) Note: Previously the ;& and ;% normal mode mappings didn't require a motion and operated on the character "under" the cursor. This was changed for multiple reasons. Use ;&l or ;%l to emulate the old behavior. *n_;^* *v_;^* ;^ This mapping will decode the &#...; and %XX elements of the motion or visually selected characters their actual characters. (|n_;|) The following mappings work in insert mode only. Note that you can change the leader character for these mappings from '&' to another character of your preference. See |g:html_map_entity_leader|. Name: HTML: Macro: -------------------------------------------------------------------- Ampersand (&) & && *i_&&* Greater than (>) > &> *i_&>* Less than (<) < &< *i_&<* *i_&* *i_&space* *i_;* Space (non-breaking)   &/; *i_;space* Quotation mark (") " &' *i_&'* Cent ¢ &c| *i_&cbar* Pound £ &# *i_&#* Yen ¥ &Y= *i_&Y=* Left Angle Quote « &2< *i_&2<* Right Angle Quote » &2> *i_&2>* Copyright © &cO *i_&cO* Registered ® &rO *i_&rO* Trademark ™ &tm *i_&tm* Multiply × &x *i_&x* Divide ÷ &/ *i_&/* Inverted Exclamation ¡ &! *i_&!* Inverted Question ¿ &? *i_&?* Degree ° &dg *i_&dg* Micro µ &mi *i_&mi* Paragraph ¶ &pa *i_&pa* Middle Dot · &. *i_&.* One Quarter ¼ &14 *i_&14* One Half ½ &12 *i_&12* Three Quarters ¾ &34 *i_&34* En dash – &n-/&2- *i_&n-* *i_&2-* Em dash — &m-/&--/&3- *i_&m-* *i_&--* *i_3-* Ellipsis … &3. *i_&3.* A-grave À &A` *i_&A`* a-grave à &a` *i_&a`* E-grave È &E` *i_&E`* e-grave è &e` *i_&e`* I-grave Ì &I` *i_&I`* i-grave ì &i` *i_&i`* O-grave Ò &O` *i_&O`* o-grave ò &o` *i_&o`* U-grave Ù &U` *i_&U`* u-grave ù &u` *i_&u`* A-acute Á &A' *i_&A'* a-acute á &a' *i_&a'* E-acute É &E' *i_&E'* e-acute é &e' *i_&e'* I-acute Í &I' *i_&I'* i-acute í &i' *i_&i'* O-acute Ó &O' *i_&O'* o-acute ó &o' *i_&o'* U-acute Ú &U' *i_&U'* u-acute ú &u' *i_&u'* Y-acute Ý &Y' *i_&Y'* y-acute ý &y' *i_&y'* A-tilde à &A~ *i_&A~* a-tilde ã &a~ *i_&a~* N-tilde Ñ &N~ *i_&N~* n-tilde ñ &n~ *i_&n~* O-tilde Õ &O~ *i_&O~* o-tilde õ &o~ *i_&o~* A-circumflex  &A^ *i_&A^* a-circumflex â &a^ *i_&a^* E-circumflex Ê &E^ *i_&E^* e-circumflex ê &e^ *i_&e^* I-circumflex Î &I^ *i_&I^* i-circumflex î &i^ *i_&i^* O-circumflex Ô &O^ *i_&O^* o-circumflex ô &o^ *i_&o^* U-circumflex Û &U^ *i_&U^* u-circumflex û &u^ *i_&u^* A-umlaut Ä &A" *i_&Aquote* a-umlaut ä &a" *i_&aquote* E-umlaut Ë &E" *i_&Equote* e-umlaut ë &e" *i_&equote* I-umlaut Ï &I" *i_&Iquote* i-umlaut ï &i" *i_&iquote* O-umlaut Ö &O" *i_&Oquote* o-umlaut ö &o" *i_&oquote* U-umlaut Ü &U" *i_&Uquote* u-umlaut ü &u" *i_&uquote* y-umlaut ÿ &y" *i_&yquote* Umlaut ¨ &" *i_"e* A-ring Å &Ao *i_&Ao* a-ring å &ao *i_&ao* AE-ligature Æ &AE *i_&AE* ae-ligature æ &ae *i_&ae* C-cedilla Ç &C, *i_&C,* c-cedilla ç &c, *i_&c,* O-slash Ø &O/ *i_&O/* o-slash ø &o/ *i_&o/* Left single arrow ← &la *i_&la* Right single arrow → &ra *i_&ra* Up single arrow ↑ &ua *i_&ua* Down single arrow ↓ &da *i_&da* Left-right single arrow ↔ &ha *i_&ha* Left double arrow ⇐ &lA *i_&lA* Right double arrow ⇒ &rA *i_&rA* Up double arrow ⇑ &uA *i_&uA* Down double arrow ⇓ &dA *i_&dA* Left-right double arrow ⇔ &hA *i_&hA* The greek alphabet: Name: HTML: Macro: -------------------------------------------------------------------- Upper Alpha Α &Al *i_&Al* Upper Beta Β &Be *i_&Be* Upper Gamma Γ &Ga *i_&Ga* Upper Delta Δ &De *i_&De* Upper Epsilon Ε &Ep *i_&Ep* Upper Zeta Ζ &Ze *i_&Ze* Upper Eta Η &Et *i_&Et* Upper Theta Θ &Th *i_&Th* Upper Iota Ι &Io *i_&Io* Upper Kappa Κ &Ka *i_&Ka* Upper Lambda Λ &Lm *i_&Lm* Upper Mu Μ &Mu *i_&Mu* Upper Nu Ν &Nu *i_&Nu* Upper Xi Ξ &Xi *i_&Xi* Upper Omicron Ο &Oc *i_&Oc* Upper Pi Π &Pi *i_&Pi* Upper Rho Ρ &Rh *i_&Rh* Upper Sigma Σ &Si *i_&Si* Upper Tau Τ &Ta *i_&Ta* Upper Upsilon Υ &Up *i_&Up* Upper Phi Φ &Ph *i_&Ph* Upper Chi Χ &Ch *i_&Ch* Upper Psi Ψ &Ps *i_&Ps* Lower alpha α &al *i_&al* Lower beta β &be *i_&be* Lower gamma γ &ga *i_&ga* Lower delta δ &de *i_&de* Lower epsilon ε &ep *i_&ep* Lower zeta ζ &ze *i_&ze* Lower eta η &et *i_&et* Lower theta θ &th *i_&th* Lower iota ι &io *i_&io* Lower kappa κ &ka *i_&ka* Lower lambda λ &lm *i_&lm* Lower mu μ &mu *i_&mu* Lower nu ν &nu *i_&nu* Lower xi ξ &xi *i_&xi* Lower omicron ο &oc *i_&oc* Lower pi π &pi *i_&pi* Lower rho ρ &rh *i_&rh* Lower sigma σ &si *i_&si* Lower sigmaf ς &sf *i_&sf* Lower tau τ &ta *i_&ta* Lower upsilon υ &up *i_&up* Lower phi φ &ph *i_&ph* Lower chi χ &ch *i_&ch* Lower psi ψ &ps *i_&ps* Lower omega ω &og *i_&og* Lower thetasym ϑ &ts *i_&ts* Lower upsih ϒ &uh *i_&uh* Lower piv ϖ &pv *i_&pv* ============================================================================== 6. How to Use Browser Mappings *browser-control* You can use a browser to preview your current HTML document. (See |html-author-notes|) For Windows: *n_;db* ;db Call the default browser on the current file. *n_;ie* ;ie Call Explorer on the current file. For Unix: The following mappings are only defined if you have properly installed the browser_launcher.vim script, available with installation instructions here: http://www.infynity.spodzone.com/vim/HTML/ *n_;ff* ;ff Make Firefox view the current file, starting Firefox if it is not running. *n_;nff* ;nff Same as |;ff|, but start a new browser window. *n_;tff* ;tff Same as |;nff|, but open a new tab. *n_;mo* ;mo Make Mozilla view the current file, starting Mozilla if it is not running. *n_;nmo* ;nmo Same as |;mo|, but start a new browser window. *n_;tmo* ;tmo Same as |;nmo|, but open a new tab. *n_;ne* ;ne Make Netscape view the current file, starting Netscape if it is not running. *n_;nne* ;nne Same as |;ne|, but start a new browser window. Note: If Firefox and/or Mozilla and/or Netscape are running, these mappings may behave somewhat unexpectedly, due to the fact that Firefox, Mozilla and Netscape use the same remote protocol IDs. *n_;oa* ;oa Make Opera view the current file, starting Opera if it is not running. *n_;noa* ;noa Same as |;oa|, but start a new browser window. *n_;toa* ;toa Same as |;noa|, but open a new tab. *n_;ly* ;ly Use lynx to view the current file. This behaves like |;nly| if the Vim GUI is running. *n_;nly* ;nly Same as |;ly|, but in a new xterm. This behaves like |;ly| if there is no DISPLAY environmental variable. *n_;w3* ;w3 Use w3m to view the current file. This behaves like |;nw3| if the Vim GUI is running. *n_;nw3* ;nw3 Same as |;w3|, but in a new xterm. This behaves like |;w3| if there is no DISPLAY environmental variable. ============================================================================== 7. Miscellaneous Extras *html-misc* :SetIfUnset {variable} {value} *:SetIfUnset* This calls |SetIfUnset()|. Functions used by the HTML mappings: *html-functions* ------------------------------------ HTMLencodeString({string} [, {...}]) *HTMLencodeString()* Returns {string} encoded into HTML entities. If the second argument is "%" the string is encoded into %XX hexadecimal string instead. If the second argument is "d" or "decode" the &#...; and %XX elements of the provided string will be decoded into their actual characters. See |n_;&| and |n_;%| for examples. Note that Unicode characters can not be safely converted to %XX hex strings for URIs do to a limit in the specification. HTMLgenerateTable() *HTMLgenerateTable()* This is normally called by the normal mapping |;ta|, but it works the same if called any other way. HTMLmap({maptype}, {lhs}, {rhs} [, {re-indent}]) *HTMLmap()* This function defines a mapping, local to the buffer and silent. {maptype} is any map command. {lhs} and {rhs} are equivalent to :map arguments, see |map.txt|. This is useful for autocommands and HTML filetype plugins. If {lhs} starts with "" that string will replaced with the contents of |g:html_map_leader|. If {lhs} starts with "" that string will replaced with the contents of |g:html_map_entity_leader|. Any text in {rhs} that is enclosed by [{}] will be converted to uppercase/lowercase according to the |g:html_tag_case| variable, and the [{}] markers will be removed. {re-indent} is optional, applies only to visual maps when filetype indenting is enabled, and should not be used for maps that enter insert mode. If the value is 1, the visually selected area is re-selected, plus one line below, and re-indented. A value of 2 does the same without moving down a line. The special cases of 0 means the visual mapping enters visual mode, and -1 tells the function not to add any special extra code to the visual mapping. Note that more "magic" than what's documented here gets applied to the mappings depending on their mode, the value of {re-indent} and so on. HTMLmapo({map}, {insert}) *HTMLmapo()* Creates an operator-pending mapping wrapper for {map} that calls the visual mapping by the same name. {insert} is a boolean value (0 or 1) that indicates whether to end in insert mode. HTMLnextInsertPoint([{mode}]) *HTMLnextInsertPoint()* This is normally called by the |;| mapping, but it works the same if called any other way. The {mode} argument is either 'i' or 'n' (default) which means |Insert| or |Normal|. In insert mode, if the cursor is on the start of a closing tag it places the cursor after the tag. HTMLtemplate() *HTMLtemplate()* This is normally called by the normal mapping |;html|, but it works the same if called any other way. SetIfUnset({variable}, {value}) *SetIfUnset()* This function sets {variable} to {value} if the variable is not already set. A {value} of "-" makes sure the variable is set with an empty string. This function will not work for function-local variables. (|l:var|) Author's notes: *html-author-notes* --------------- The Content-Type charset automatic detection value based on the 'fileencoding' / 'encoding' option has a very incomplete translation table from the possible values that Vim uses--I could use help with this. I want to finally release a 1.0 version, but I am not willing to until I have browser control mappings for operating systems other than *nix. Unfortunately I need substantial help to create them for Windows and MacOS since I do not have access to either OS. I will never include mappings for certain tags, such as and . As far as I am concerned these tags should never have existed. (I disable these "features" completely in my browser.) vim:tw=78:ts=8:sw=8:ft=help:fo=tcq2:ai: ftplugin/html/HTML.vim [[[1 3231 " ---- Author & Copyright: ---------------------------------------------- {{{1 " " Author: Christian J. Robinson " URL: http://www.infynity.spodzone.com/vim/HTML/ " Last Change: June 20, 2008 " Version: 0.35.3 " Original Concept: Doug Renze " " " The original Copyright goes to Doug Renze, although nearly all of his " efforts have been modified in this implementation. My changes and additions " are Copyrighted by me, on the dates marked in the ChangeLog. " " (Doug Renze has authorized me to place the original "code" under the GPL.) " " ---------------------------------------------------------------------------- " " This program is free software; you can redistribute it and/or modify it " under the terms of the GNU General Public License as published by the Free " Software Foundation; either version 2 of the License, or (at your option) " any later version. " " This program is distributed in the hope that it will be useful, but WITHOUT " ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or " FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for " more details. " " ---- Original Author's Notes: ---------------------------------------------- " " HTML Macros " I wrote these HTML macros for my personal use. They're " freely-distributable and freely-modifiable. " " If you do make any major additions or changes, or even just " have a suggestion for improvement, feel free to let me " know. I'd appreciate any suggestions. " " Credit must go to Eric Tilton, Carl Steadman and Tyler " Jones for their excellent book "Web Weaving" which was " my primary source. " " Doug Renze " " ---- TODO: ------------------------------------------------------------ {{{1 " " - Specific browser mappings for Win32 with "start ..." ? " - Find a way to make "gv" after executing a visual mapping re-select the " right text. (Currently my extra code that wraps around the visual " mappings can tweak the selected area significantly.) " + This should probably exclude the newly created tags, so things like " visual selection ;ta, then gv and ;tr, then gv and ;td work. " - Add :HTMLmappingsreload/html/xhtml to the HTML menu? " " ---- RCS Information: ------------------------------------------------- {{{1 " $Id: HTML.vim,v 1.205 2008/06/20 08:11:11 infynity Exp $ " ----------------------------------------------------------------------- }}}1 " ---- Initialization: -------------------------------------------------- {{{1 if v:version < 700 echoerr "HTML.vim no longer supports Vim versions prior to 7." sleep 2 finish "elseif v:version < 700 " let s:tmp = " \ "The HTML macros support for Vim versions prior to 7\n" . " \ "will be abandoned in future versions.\n\n" . " \ "You should seriously consider upgrading your version of Vim." " call confirm(s:tmp, "&Dismiss", 1, 'Warning') " unlet s:tmp endif " Save cpoptions and remove some junk that will throw us off (reset at the end " of the script): let s:savecpo = &cpoptions set cpoptions&vim let s:doing_internal_html_mappings = 1 if ! exists("b:did_html_mappings_init") let b:did_html_mappings_init = 1 setlocal matchpairs+=<:> " ---- Init Functions: -------------------------------------------------- {{{2 " s:BoolVar() {{{3 " " Given a string, test to see if a variable by that string name exists, and if " so, whether it's set to 1|true|yes / 0|false|no (Actually, anything not " listed here also returns as 1.) " " Arguments: " 1 - String: The name of the variable to test (not its value!) " Return Value: " 1/0 " " Limitations: " This /will not/ work on function-local variable names. function! s:BoolVar(var) if a:var =~ '^[bgstvw]:' let var = a:var else let var = 'g:' . a:var endif if s:IsSet(var) execute "let varval = " . var return s:Bool(varval) else return 0 endif endfunction " s:Bool() {{{3 " " Helper to s:BoolVar() -- Test the string passed to it and return true/false " based on that string. " " Arguments: " 1 - String: 1|true|yes / 0|false|no " Return Value: " 1/0 function! s:Bool(str) return a:str !~? '^no$\|^false$\|^0$\|^$' endfunction " SetIfUnset() {{{3 " " Set a variable if it's not already set. " " Arguments: " 1 - String: The variable name " 2 ... N - String: The default value to use, "-" for the null string " Return Value: " 0 - The variable already existed " 1 - The variable didn't exist and was set " -1 - An error occurred function! SetIfUnset(var, ...) if a:var =~ '^[bgstvw]:' let var = a:var else let var = 'g:' . a:var endif if a:0 == 0 echohl ErrorMsg echomsg "E119: Not enough arguments for function: SetIfUnset" echohl None return -1 else let val = join(a:000, ' ') endif if ! s:IsSet(var) if val == "-" execute "let " . var . "= \"\"" else execute "let " . var . "= val" endif return 1 endif return 0 endfunction " s:IsSet() {{{3 " " Given a string, test to see if a variable by that string name exists. " " Arguments: " 1 - String: The variable name " Return Value: " 1/0 function! s:IsSet(str) execute "let varisset = exists(\"" . a:str . "\")" return varisset endfunction "}}}3 " ----------------------------------------------------------------------- }}}2 command! -nargs=+ SetIfUnset call SetIfUnset() SetIfUnset g:html_bgcolor #FFFFFF SetIfUnset g:html_textcolor #000000 SetIfUnset g:html_linkcolor #0000EE SetIfUnset g:html_alinkcolor #FF0000 SetIfUnset g:html_vlinkcolor #990066 SetIfUnset g:html_tag_case uppercase SetIfUnset g:html_map_leader ; SetIfUnset g:html_map_entity_leader & SetIfUnset g:html_default_charset iso-8859-1 " No way to know sensible defaults here so just make sure the " variables are set: SetIfUnset g:html_authorname - SetIfUnset g:html_authoremail - if g:html_map_entity_leader ==# g:html_map_leader echohl ErrorMsg echomsg 'ERROR! "g:html_map_entity_leader" and "g:html_map_leader" have the same value!' echomsg ' Resetting "g:html_map_entity_leader" to "&".' echohl None sleep 2 let g:html_map_entity_leader = '&' endif if exists('b:html_tag_case') let b:html_tag_case_save = b:html_tag_case endif " Detect whether to force uppper or lower case: {{{2 if &filetype ==? "xhtml" \ || s:BoolVar('g:do_xhtml_mappings') \ || s:BoolVar('b:do_xhtml_mappings') let b:do_xhtml_mappings = 1 else let b:do_xhtml_mappings = 0 if s:BoolVar('g:html_tag_case_autodetect') \ && (line('$') != 1 || getline(1) != '') let s:found_upper = search('\C<\(\s*/\)\?\s*\u\+\_[^<>]*>', 'wn') let s:found_lower = search('\C<\(\s*/\)\?\s*\l\+\_[^<>]*>', 'wn') if s:found_upper && ! s:found_lower let b:html_tag_case = 'uppercase' elseif ! s:found_upper && s:found_lower let b:html_tag_case = 'lowercase' endif unlet s:found_upper s:found_lower endif endif if s:BoolVar('b:do_xhtml_mappings') let b:html_tag_case = 'lowercase' endif " }}}2 call SetIfUnset('b:html_tag_case', g:html_tag_case) let s:thisfile = expand(":p") " ---------------------------------------------------------------------------- " ---- Functions: ------------------------------------------------------- {{{1 if ! exists("g:did_html_functions") let g:did_html_functions = 1 " HTMLencodeString() {{{2 " " Encode the characters in a string into their HTML &#...; representations. " " Arguments: " 1 - String: The string to encode. " 2 - String: Optional, whether to decode rather than encode the string: " d/decode: Decode the &#...; elements of the provided string " anything else: Encode the string (default) " Return Value: " String: The encoded string. function! HTMLencodeString(string, ...) let out = '' if a:0 > 0 if a:1 =~? '^d\(ecode\)\=$' let out = substitute(a:string, '&#\(\d\+\);', '\=nr2char(submatch(1))', 'g') let out = substitute(out, '%\(\x\{2}\)', '\=nr2char("0x".submatch(1))', 'g') return out elseif a:1 == '%' let out = substitute(a:string, '\(.\)', '\=printf("%%%02X", char2nr(submatch(1)))', 'g') return out endif endif let string = split(a:string, '\zs') for c in string let out = out . '&#' . char2nr(c) . ';' endfor return out endfunction " HTMLmap() {{{2 " " Define the HTML mappings with the appropriate case, plus some extra stuff. " " Arguments: " 1 - String: Which map command to run. " 2 - String: LHS of the map. " 3 - String: RHS of the map. " 4 - Integer: Optional, applies only to visual maps: " -1: Don't add any extra special code to the mapping. " 0: Mapping enters insert mode. " Applies only when filetype indenting is on: " 1: re-selects the region, moves down a line, and re-indents. " 2: re-selects the region and re-indents. " (Don't use these two arguments for maps that enter insert " mode!) let s:modes = { \ 'n': 'normal', \ 'v': 'visual', \ 'o': 'operator-pending', \ 'i': 'insert', \ 'c': 'command-line', \ 'l': 'langmap', \} function! HTMLmap(cmd, map, arg, ...) let mode = strpart(a:cmd, 0, 1) let map = substitute(a:map, '^\c', escape(g:html_map_leader, '&~\'), '') let map = substitute(map, '^\c', escape(g:html_map_entity_leader, '&~\'), '') if exists('s:modes[mode]') && s:MapCheck(map, mode) >= 2 return endif let arg = s:ConvertCase(a:arg) if ! s:BoolVar('b:do_xhtml_mappings') let arg = substitute(arg, ' \?/>', '>', 'g') endif if mode == 'v' " If 'selection' is "exclusive" all the visual mode mappings need to " behave slightly differently: let arg = substitute(arg, "`>a\\C", "`>i=VI()", 'g') if a:0 >= 1 && a:1 < 0 execute a:cmd . " " . map . " " . arg elseif a:0 >= 1 && a:1 >= 1 execute a:cmd . " " . map . " :call TO(0)gv" . arg \ . ":call TO(1)m':call ReIndent(line(\"'<\"), line(\"'>\"), " . a:1 . ")``" elseif a:0 >= 1 execute a:cmd . " " . map . " :call TO(0)gv" . arg \ . ":call TO(1)" else execute a:cmd . " " . map . " :call TO(0)gv" . arg \ . ":call TO(1)" endif else execute a:cmd . " " . map . " " . arg endif if exists('s:modes[mode]') let b:HTMLclearMappings = b:HTMLclearMappings . ':' . mode . "unmap " . map . "\" else let b:HTMLclearMappings = b:HTMLclearMappings . ":unmap " . map . "\" endif call s:ExtraMappingsAdd(':call HTMLmap("' . a:cmd . '", "' . escape(a:map, '"\') \ . '", "' . escape(a:arg, '"\') . (a:0 >= 1 ? ('", ' . a:1) : '"' ) . ')') endfunction " HTMLmapo() {{{2 " " Define a map that takes an operator to its corresponding visual mode " mapping. " " Arguments: " 1 - String: The mapping. " 2 - Boolean: Whether to enter insert mode after the mapping has executed. " (A value greater than 1 tells the mapping not to move right one " character.) function! HTMLmapo(map, insert) let map = substitute(a:map, "^", g:html_map_leader, '') if s:MapCheck(map, 'o') >= 2 return endif execute 'nnoremap ' . map \ . " :let b:htmltagaction='" . map . "'" \ . ":let b:htmltaginsert=" . a:insert . "" \ . ':set operatorfunc=WRg@' let b:HTMLclearMappings = b:HTMLclearMappings . ":nunmap " . map . "\" call s:ExtraMappingsAdd(':call HTMLmapo("' . escape(a:map, '"\') . '", ' . a:insert . ')') endfunction " s:MapCheck() {{{2 " " Check to see if a mapping for a mode already exists. If there is, and " overriding hasn't been suppressed, print an error. " " Arguments: " 1 - String: The map sequence (LHS). " 2 - Character: The mode for the mapping. " Return Value: " 0 - No mapping was found. " 1 - A mapping was found, but overriding has /not/ been suppressed. " 2 - A mapping was found and overriding has been suppressed. " 3 - The mapping to be defined was suppressed by g:no_html_maps. " " (Note that suppression only works for the internal mappings.) function! s:MapCheck(map, mode) if exists('s:doing_internal_html_mappings') && \ ( (exists('g:no_html_maps') && a:map =~# g:no_html_maps) || \ (exists('b:no_html_maps') && a:map =~# b:no_html_maps) ) return 3 elseif exists('s:modes[a:mode]') && maparg(a:map, a:mode) != '' if s:BoolVar('g:no_html_map_override') && exists('s:doing_internal_html_mappings') return 2 else echohl WarningMsg echomsg "WARNING: A mapping to \"" . a:map . "\" for " . s:modes[a:mode] . " mode has been overridden for this buffer." echohl None return 1 endif endif return 0 endfunction " s:WR() {{{2 " Function set in 'operatorfunc' for mappings that take an operator: function! s:WR(type) let sel_save = &selection let &selection = "inclusive" if a:type == 'line' execute "normal `[V`]" . b:htmltagaction elseif a:type == 'block' execute "normal `[\`]" . b:htmltagaction else execute "normal `[v`]" . b:htmltagaction endif let &selection = sel_save if b:htmltaginsert if b:htmltaginsert < 2 execute "normal \" endif startinsert endif " Leave these set so .-repeating of operator mappings works: "unlet b:htmltagaction b:htmltaginsert endfunction " s:ExtraMappingsAdd() {{{2 " " Add to the b:HTMLextraMappings variable if necessary. " " Arguments: " 1 - String: The command necessary to re-define the mapping. function! s:ExtraMappingsAdd(arg) if ! exists('s:doing_internal_html_mappings') && ! exists('s:doing_extra_html_mappings') if ! exists('b:HTMLextraMappings') let b:HTMLextraMappings = '' endif let b:HTMLextraMappings = b:HTMLextraMappings . a:arg . ' |' endif endfunction " s:TO() {{{2 " " Used to make sure the 'showmatch', 'indentexpr', and 'formatoptions' options " are off temporarily to prevent the visual mappings from causing a " (visual)bell or inserting improperly. " " Arguments: " 1 - Integer: 0 - Turn options off. " 1 - Turn options back on, if they were on before. function! s:TO(s) if a:s == 0 let s:savesm=&l:sm | let &l:sm=0 let s:saveinde=&l:inde | let &l:inde='' let s:savefo=&l:fo | let &l:fo='' " A trick to make leading indent on the first line of visual-line " selections is handled properly (turn it into a character-wise " selection and exclude the leading indent): if visualmode() ==# 'V' let s:visualmode_save = visualmode() exe "normal `<^v`>\" endif else let &l:sm=s:savesm | unlet s:savesm let &l:inde=s:saveinde | unlet s:saveinde let &l:fo=s:savefo | unlet s:savefo " Restore the last visual mode if it was changed: if exists('s:visualmode_save') exe "normal gv" . s:visualmode_save . "\" unlet s:visualmode_save endif endif endfunction " s:TC() {{{2 " " Used to make sure the 'comments' option is off temporarily to prevent " certain mappings from inserting unwanted comment leaders. " " Arguments: " 1 - Integer: 0 - Turn options off. " 1 - Turn options back on, if they were on before. function! s:TC(s) if a:s == 0 let s:savecom=&l:com | let &l:com='' else let &l:com=s:savecom | unlet s:savecom endif endfunction " s:VI() {{{2 " " Used by HTMLmap() to enter insert mode in Visual mappings in the right " place, depending on what 'selection' is set to. " " Arguments: " None " Return Value: " The proper movement command based on the value of 'selection'. function! s:VI() if &selection == 'inclusive' return "\" else return "\`>" endif endfunction " s:ConvertCase() {{{2 " " Convert special regions in a string to the appropriate case determined by " b:html_tag_case. " " Arguments: " 1 - String: The string with the regions to convert surrounded by [{...}]. " Return Value: " The converted string. function! s:ConvertCase(str) if (! exists('b:html_tag_case')) || b:html_tag_case =~? 'u\(pper\(case\)\?\)\?' || b:html_tag_case == '' let str = substitute(a:str, '\[{\(.\{-}\)}\]', '\U\1', 'g') elseif b:html_tag_case =~? 'l\(ower\(case\)\?\)\?' let str = substitute(a:str, '\[{\(.\{-}\)}\]', '\L\1', 'g') else echohl WarningMsg echomsg "WARNING: b:html_tag_case = '" . b:html_tag_case . "' invalid, overriding to 'upppercase'." echohl None let b:html_tag_case = 'uppercase' let str = s:ConvertCase(a:str) endif return str endfunction " s:ReIndent() {{{2 " " Re-indent a region. (Usually called by HTMLmap.) " Nothing happens if filetype indenting isn't enabled or 'indentexpr' is " unset. " " Arguments: " 1 - Integer: Start of region. " 2 - Integer: End of region. " 3 - Integer: 1: Add an extra line below the region to re-indent. " *: Don't add an extra line. function! s:ReIndent(first, last, extraline) " To find out if filetype indenting is enabled: let save_register = @x redir @x | silent! filetype | redir END let filetype_output = @x let @x = save_register if filetype_output =~ "indent:OFF" && &indentexpr == '' return endif " Make sure the range is in the proper order: if a:last >= a:first let firstline = a:first let lastline = a:last else let lastline = a:first let firstline = a:last endif " Make sure the full region to be re-indendted is included: if a:extraline == 1 if firstline == lastline let lastline = lastline + 2 else let lastline = lastline + 1 endif endif execute firstline . ',' . lastline . 'norm ==' endfunction " s:ByteOffset() {{{2 " " Return the byte number of the current position. " " Arguments: " None " Return Value: " The byte offset function! s:ByteOffset() return line2byte(line('.')) + col('.') - 1 endfunction " HTMLnextInsertPoint() {{{2 " " Position the cursor at the next point in the file that needs data. " " Arguments: " 1 - Character: Optional, the mode the function is being called from. 'n' " for normal, 'i' for insert. If 'i' is used the function " enables an extra feature where if the cursor is on the start " of a closing tag it places the cursor after the tag. " Default is 'n'. " Return Value: " None. " Known problems: " Due to the necessity of running the search twice (why doesn't Vim support " cursor offset positioning in search()?) this function " a) won't ever position the cursor on an "empty" tag that starts on the " first character of the first line of the buffer " b) won't let the cursor "escape" from an "empty" tag that it can match on " the first line of the buffer when the cursor is on the first line and " tab is successively pressed function! HTMLnextInsertPoint(...) let saveerrmsg = v:errmsg let v:errmsg = '' let saveruler = &ruler | let &ruler=0 let saveshowcmd = &showcmd | let &showcmd=0 let byteoffset = s:ByteOffset() " Tab in insert mode on the beginning of a closing tag jumps us to " after the tag: if a:0 >= 1 && a:1 == 'i' if strpart(getline(line('.')), col('.') - 1, 2) == '' normal f> let done = 1 else let done = 0 endif if done == 1 if col('.') == col('$') - 1 startinsert! else normal l endif return endif endif normal 0 " Running the search twice is inefficient, but it squelches error " messages and the second search puts my cursor where it's needed... if search('<\([^ <>]\+\)\_[^<>]*>\_s*<\/\1>\|<\_[^<>]*""\_[^<>]*>\|', 'w') == 0 if byteoffset == -1 go 1 else execute ':go ' . byteoffset if a:0 >= 1 && a:1 == 'i' && col('.') == col('$') - 1 startinsert! endif endif else normal 0 silent! execute ':go ' . s:ByteOffset() - 1 execute 'silent! normal! /<\([^ <>]\+\)\_[^<>]*>\_s*<\/\1>\|<\_[^<>]*""\_[^<>]*>\|/;/>\_s*<\|""\|/e' . "\" " Handle cursor positioning for comments and/or open+close tags spanning " multiple lines: if getline('.') =~ '' execute "normal F\" elseif getline('.') =~ '^ *-->' && getline(line('.')-1) =~ '' && getline(line('.')-1) =~ '^ *$' normal k$ elseif getline('.') =~ '^ *<\/[^<>]\+>' && getline(line('.')-1) =~ '^ *$' normal k$ endif call histdel('search', -1) let @/ = histget('search', -1) endif let v:errmsg = saveerrmsg let &ruler = saveruler let &showcmd = saveshowcmd endfunction " s:tag() {{{2 " " Causes certain tags (such as bold, italic, underline) to be closed then " opened rather than opened then closed where appropriate, if syntax " highlighting is on. " " Arguments: " 1 - String: The tag name. " 2 - Character: The mode: " 'i' - Insert mode " 'v' - Visual mode " Return Value: " The string to be executed to insert the tag. " s:smarttags[tag][mode][open/close] = keystrokes {{{ " tag - The literal tag, without the <>'s " mode - i = insert, v = visual " (no "o", because o-mappings invoke visual mode) " open/close - c = When inside an equivalent tag, close then open it " o = When not inside an equivalent tag " keystrokes - The mapping keystrokes to execute let s:smarttags = {} let s:smarttags['i'] = { \ 'i': { \ 'o': "<[{I>\F<", \ 'c': "<[{/I>\F<", \ }, \ 'v': { \ 'o': "`>a\`<<[{I}]>", \ 'c': "`>a<[{I}]>\`<", \ } \ } let s:smarttags['em'] = { \ 'i': { \ 'o': "<[{EM>\F<", \ 'c': "<[{/EM>\F<", \ }, \ 'v': { \ 'o': "`>a\`<<[{EM}]>", \ 'c': "`>a<[{EM}]>\`<", \ } \ } let s:smarttags['b'] = { \ 'i': { \ 'o': "<[{B>\F<", \ 'c': "<[{/B>\F<", \}, \ 'v': { \ 'o': "`>a\`<<[{B}]>", \ 'c': "`>a<[{B}]>\`<", \ } \ } let s:smarttags['strong'] = { \ 'i': { \ 'o': "<[{STRONG>\F<", \ 'c': "<[{/STRONG>\F<", \}, \ 'v': { \ 'o': "`>a\`<<[{STRONG}]>", \ 'c': "`>a<[{STRONG}]>\`<", \ } \ } let s:smarttags['u'] = { \ 'i': { \ 'o': "<[{U>\F<", \ 'c': "<[{/U>\F<", \}, \ 'v': { \ 'o': "`>a\`<<[{U}]>", \ 'c': "`>a<[{U}]>\`<", \ } \ } let s:smarttags['comment'] = { \ 'i': { \ 'o': "\F ", \ 'c': " -->\`<", \ } \ } " }}} function! s:tag(tag, mode) let attr=synIDattr(synID(line('.'), col('.') - 1, 1), "name") if ( a:tag == 'i' && attr =~? 'italic' ) \ || ( a:tag == 'em' && attr =~? 'italic' ) \ || ( a:tag == 'b' && attr =~? 'bold' ) \ || ( a:tag == 'strong' && attr =~? 'bold' ) \ || ( a:tag == 'u' && attr =~? 'underline' ) \ || ( a:tag == 'comment' && attr =~? 'comment' ) let ret=s:ConvertCase(s:smarttags[a:tag][a:mode]['c']) else let ret=s:ConvertCase(s:smarttags[a:tag][a:mode]['o']) endif if a:mode == 'v' " If 'selection' is "exclusive" all the visual mode mappings need to " behave slightly differently: let ret = substitute(ret, "`>a\\C", "`>i" . s:VI(), 'g') endif return ret endfunction " s:DetectCharset() {{{2 " " Detects the HTTP-EQUIV Content-Type charset based on Vim's current " encoding/fileencoding. " " Arguments: " None " Return Value: " The value for the Content-Type charset based on 'fileencoding' or " 'encoding'. " TODO: This table needs to be expanded: let s:charsets = {} let s:charsets['latin1'] = 'iso-8859-1' let s:charsets['utf_8'] = 'UTF-8' let s:charsets['utf_16'] = 'UTF-16' let s:charsets['shift_jis'] = 'Shift_JIS' let s:charsets['euc_jp'] = 'EUC-JP' let s:charsets['cp950'] = 'Big5' let s:charsets['big5'] = 'Big5' function! s:DetectCharset() if exists("g:html_charset") return g:html_charset endif if &fileencoding != '' let enc=tolower(&fileencoding) else let enc=tolower(&encoding) endif " The iso-8859-* encodings are valid for the Content-Type charset header: if enc =~? '^iso-8859-' return enc endif let enc=substitute(enc, '\W', '_', 'g') if s:charsets[enc] != '' return s:charsets[enc] endif return g:html_default_charset endfunction " HTMLgenerateTable() {{{2 " " Interactively creates a table. " " Arguments: " None " Return Value: " None function! HTMLgenerateTable() let byteoffset = s:ByteOffset() let rows = inputdialog("Number of rows: ") + 0 let columns = inputdialog("Number of columns: ") + 0 if ! (rows > 0 && columns > 0) echo "Rows and columns must be integers." return endif let border = inputdialog("Border width of table [none]: ") + 0 if border execute s:ConvertCase("normal o<[{TABLE BORDER}]=" . border . ">\") else execute s:ConvertCase("normal o<[{TABLE}]>\") endif for r in range(rows) execute s:ConvertCase("normal o<[{TR}]>\") for c in range(columns) execute s:ConvertCase("normal o<[{TD}]>\\") endfor execute s:ConvertCase("normal o\") endfor execute s:ConvertCase("normal o\") execute ":go " . (byteoffset <= 0 ? 1 : byteoffset) normal jjj^ endfunction " s:MappingsControl() {{{2 " " Disable/enable all the mappings defined by HTMLmap()/HTMLmapo(). " " Arguments: " 1 - String: Whether to disable or enable the mappings: " d/disable: Clear the mappings " e/enable: Redefine the mappings " r/reload: Completely reload the script " h/html: Reload the mapppings in HTML mode " x/xhtml: Reload the mapppings in XHTML mode " Return Value: " None silent! function! s:MappingsControl(dowhat) if ! exists('b:did_html_mappings_init') echohl ErrorMsg echomsg "The HTML mappings were not sourced for this buffer." echohl None return endif if b:did_html_mappings_init < 0 unlet b:did_html_mappings_init endif if a:dowhat =~? '^d\(isable\)\=\|off$' if exists('b:did_html_mappings') silent execute b:HTMLclearMappings unlet b:did_html_mappings if exists("g:did_html_menus") call s:MenuControl('disable') endif elseif ! exists('s:quiet_errors') echohl ErrorMsg echomsg "The HTML mappings are already disabled." echohl None endif elseif a:dowhat =~? '^e\(nable\)\=\|on$' if exists('b:did_html_mappings') echohl ErrorMsg echomsg "The HTML mappings are already enabled." echohl None else execute "source " . s:thisfile if exists('b:HTMLextraMappings') let s:doing_extra_html_mappings = 1 silent execute b:HTMLextraMappings unlet s:doing_extra_html_mappings endif endif elseif a:dowhat =~? '^r\(eload\|einit\)\=$' let s:quiet_errors = 1 HTMLmappings off let b:did_html_mappings_init=-1 silent! unlet g:did_html_menus g:did_html_toolbar g:did_html_functions silent! unmenu HTML silent! unmenu! HTML HTMLmappings on unlet s:quiet_errors elseif a:dowhat =~? '^h\(tml\)\=$' if exists('b:html_tag_case_save') let b:html_tag_case = b:html_tag_case_save endif let b:do_xhtml_mappings=0 HTMLmappings off let b:did_html_mappings_init=-1 HTMLmappings on elseif a:dowhat =~? '^x\(html\)\=$' let b:do_xhtml_mappings=1 HTMLmappings off let b:did_html_mappings_init=-1 HTMLmappings on else echohl ErrorMsg echomsg "Invalid argument: " . a:dowhat echohl None endif endfunction command! -nargs=1 HTMLmappings call MappingsControl() " s:MenuControl() {{{2 " " Disable/enable the HTML menu and toolbar. " " Arguments: " 1 - String: Optional, Whether to disable or enable the mappings: " empty: Detect which to do " "disable": Disable the menu and toolbar " "enable": Enable the menu and toolbar " Return Value: " None function! s:MenuControl(...) if a:0 > 0 if a:1 !~? '^\(dis\|en\)able$' echoerr "Invalid argument: " . a:1 return else let bool = a:1 endif else let bool = '' endif if bool == 'disable' || ! exists("b:did_html_mappings") amenu disable HTML amenu disable HTML.* if exists('g:did_html_toolbar') amenu disable ToolBar.* amenu enable ToolBar.Open amenu enable ToolBar.Save amenu enable ToolBar.SaveAll amenu enable ToolBar.Cut amenu enable ToolBar.Copy amenu enable ToolBar.Paste amenu enable ToolBar.Find amenu enable ToolBar.Replace endif if exists('b:did_html_mappings_init') && ! exists('b:did_html_mappings') amenu enable HTML amenu disable HTML.Control.* amenu enable HTML.Control amenu enable HTML.Control.Enable\ Mappings amenu enable HTML.Control.Reload\ Mappings endif elseif bool == 'enable' || exists("b:did_html_mappings_init") amenu enable HTML if exists("b:did_html_mappings") amenu enable HTML.* amenu enable HTML.Control.* amenu disable HTML.Control.Enable\ Mappings if s:BoolVar('b:do_xhtml_mappings') amenu disable HTML.Control.Switch\ to\ XHTML\ mode amenu enable HTML.Control.Switch\ to\ HTML\ mode else amenu enable HTML.Control.Switch\ to\ XHTML\ mode amenu disable HTML.Control.Switch\ to\ HTML\ mode endif if exists('g:did_html_toolbar') amenu enable ToolBar.* endif else amenu enable HTML.Control.Enable\ Mappings endif endif endfunction " s:ShowColors() {{{2 " " Create a window to display the HTML colors, highlighted " " Arguments: " None " Return Value: " None function! s:ShowColors(...) if ! exists('g:did_html_menus') echohl ErrorMsg echomsg "The HTML menu was not created." echohl None return endif if ! exists('b:did_html_mappings_init') echohl ErrorMsg echomsg "Not in an html buffer." echohl None return endif let curbuf = bufnr('%') let maxw = 0 silent new [HTML\ Colors\ Display] setlocal buftype=nofile noswapfile bufhidden=wipe for key in keys(s:color_list) if strlen(key) > maxw let maxw = strlen(key) endif endfor let col = 0 let line = '' for key in sort(keys(s:color_list)) let col+=1 let line.=repeat(' ', maxw - strlen(key)) . key . ' = ' . s:color_list[key] if col >= 2 call append('$', line) let line = '' let col = 0 else let line .= ' ' endif let key2 = substitute(key, ' ', '', 'g') execute 'syntax match hc_' . key2 . ' /' . s:color_list[key] . '/' execute 'highlight hc_' . key2 . ' guibg=' . s:color_list[key] endfor if line != '' call append('$', line) endif call append(0, [ \'+++ q = quit = page down b = page up +++', \'+++ = Go to next color +++', \'+++ or = Select color under cursor +++', \]) exe 0 exe '1,3center ' . (maxw + 13) * 2 setlocal nomodifiable syntax match hc_colorsKeys =^\%<4l\s*+++ .\+ +++$= highlight link hc_colorsKeys Comment wincmd _ noremap q c inoremap q c noremap inoremap noremap b inoremap b noremap :call search('[A-Za-z][A-Za-z ]\+ = #\x\{6\}') inoremap :call search('[A-Za-z][A-Za-z ]\+ = #\x\{6\}') if a:0 >= 1 let ext = ', "' . escape(a:1, '"') . '"' else let ext = '' endif execute 'noremap :call ColorSelect(' . curbuf . ext . ')' execute 'inoremap :call ColorSelect(' . curbuf . ext . ')' execute 'noremap <2-leftmouse> :call ColorSelect(' . curbuf . ext . ')' execute 'inoremap <2-leftmouse> :call ColorSelect(' . curbuf . ext . ')' endfunction function! s:ColorSelect(bufnr, ...) let line = getline('.') let col = col('.') let color = substitute(line, '.\{-\}\%<' . (col + 1) . 'c\([A-Za-z][A-Za-z ]\+ = #\x\{6\}\)\%>' . col . 'c.*', '\1', '') if color == line return '' endif let colora = split(color, ' = ') close if bufwinnr(a:bufnr) == -1 exe 'buffer ' . a:bufnr else exe a:bufnr . 'wincmd w' endif if a:0 >= 1 let which = a:1 else let which = 'i' endif exe 'normal ' . which . colora[1] stopinsert echo color endfunction function! s:ShellEscape(str) " {{{2 if exists('*shellescape') return shellescape(a:str) else if has('unix') return "'" . substitute(a:str, "'", "'\\\\''", 'g') . "'" else " Don't know how to properly escape for 'doze, so don't bother: return a:str endif endif endfunction " ---- Template Creation Stuff: {{{2 " HTMLtemplate() {{{3 " " Determine whether to insert the HTML template. " " Arguments: " None " Return Value: " 0 - The cursor is not on an insert point. " 1 - The cursor is on an insert point. function! HTMLtemplate() let ret = 0 let save_ruler = &ruler let save_showcmd = &showcmd set noruler noshowcmd if line('$') == 1 && getline(1) == '' let ret = s:HTMLtemplate2() else let YesNoOverwrite = confirm("Non-empty file.\nInsert template anyway?", "&Yes\n&No\n&Overwrite", 2, "W") if YesNoOverwrite == 1 let ret = s:HTMLtemplate2() elseif YesNoOverwrite == 3 execute "1,$delete" let ret = s:HTMLtemplate2() endif endif let &ruler = save_ruler let &showcmd = save_showcmd return ret endfunction " }}}3 " s:HTMLtemplate2() {{{3 " " Actually insert the HTML template. " " Arguments: " None " Return Value: " 0 - The cursor is not on an insert point. " 1 - The cursor is on an insert point. function! s:HTMLtemplate2() if g:html_authoremail != '' let g:html_authoremail_encoded = HTMLencodeString(g:html_authoremail) else let g:html_authoremail_encoded = '' endif let template = '' if exists('b:html_template') && b:html_template != '' let template = b:html_template elseif exists('g:html_template') && g:html_template != '' let template = g:html_template endif if template != '' if filereadable(expand(template)) silent execute "0read " . template else echohl ErrorMsg echomsg "Unable to insert template file: " . template echomsg "Either it doesn't exist or it isn't readable." echohl None return 0 endif else 0put =b:internal_html_template endif if getline('$') =~ '^\s*$' $delete endif " Replace the various tokens with appropriate values: silent! %s/\C%authorname%/\=g:html_authorname/g silent! %s/\C%authoremail%/\=g:html_authoremail_encoded/g silent! %s/\C%bgcolor%/\=g:html_bgcolor/g silent! %s/\C%textcolor%/\=g:html_textcolor/g silent! %s/\C%linkcolor%/\=g:html_linkcolor/g silent! %s/\C%alinkcolor%/\=g:html_alinkcolor/g silent! %s/\C%vlinkcolor%/\=g:html_vlinkcolor/g silent! %s/\C%date%/\=strftime('%B %d, %Y')/g "silent! %s/\C%date\s*\([^%]\{-}\)\s*%/\=strftime(substitute(submatch(1),'\\\@DetectCharset()/g silent! %s/\C%vimversion%/\=strpart(v:version, 0, 1) . '.' . (strpart(v:version, 1, 2) + 0)/g go 1 call HTMLnextInsertPoint('n') if getline('.')[col('.') - 2] . getline('.')[col('.') - 1] == '><' \ || (getline('.') =~ '^\s*$' && line('.') != 1) return 1 else return 0 endif endfunction " }}}3 endif " ! exists("g:did_html_functions") let s:internal_html_template= \" <[{HEAD}]>\n\n" . \" <[{TITLE>\n\n" . \" <[{META NAME}]=\"Generator\" [{CONTENT}]=\"Vim %vimversion% (Vi IMproved editor; http://www.vim.org/)\" />\n" . \" <[{META NAME}]=\"Author\" [{CONTENT}]=\"%authorname%\" />\n" . \" <[{META NAME}]=\"Copyright\" [{CONTENT}]=\"Copyright (C) %date% %authorname%\" />\n" . \" <[{LINK REV}]=\"made\" [{HREF}]=\"mailto:%authoremail%\" />\n\n" . \" <[{STYLE TYPE}]=\"text/css\">\n" . \" \n" . \" \n\n" . \" \n" . \" <[{BODY BGCOLOR}]=\"%bgcolor%\"" . \" [{TEXT}]=\"%textcolor%\"" . \" [{LINK}]=\"%linkcolor%\"" . \" [{ALINK}]=\"%alinkcolor%\"" . \" [{VLINK}]=\"%vlinkcolor%\">\n\n" . \" <[{H1 ALIGN=\"CENTER\">\n\n" . \" <[{P}]>\n" . \" \n\n" . \" <[{HR WIDTH}]=\"75%\" />\n\n" . \" <[{P}]>\n" . \" Last Modified: <[{I}]>%date%\n" . \" \n\n" . \" <[{ADDRESS}]>\n" . \" <[{A HREF}]=\"mailto:%authoremail%\">%authorname% <%authoremail%>\n" . \" \n" . \" \n" . \"" if s:BoolVar('b:do_xhtml_mappings') let b:internal_html_template = "\n" . \ "\n" . \ s:internal_html_template else let b:internal_html_template = "\n" . \ "<[{HTML}]>\n" . \ s:internal_html_template let b:internal_html_template = substitute(b:internal_html_template, ' />', '>', 'g') endif let b:internal_html_template = s:ConvertCase(b:internal_html_template) " ---------------------------------------------------------------------------- endif " ! exists("b:did_html_mappings_init") " ---- Misc. Mappings: -------------------------------------------------- {{{1 if ! exists("b:did_html_mappings") let b:did_html_mappings = 1 let b:HTMLclearMappings = 'normal ' " Make it easy to use a ; (or whatever the map leader is) as normal: call HTMLmap("inoremap", '' . g:html_map_leader, g:html_map_leader) call HTMLmap("vnoremap", '' . g:html_map_leader, g:html_map_leader, -1) call HTMLmap("nnoremap", '' . g:html_map_leader, g:html_map_leader) " Make it easy to insert a & (or whatever the entity leader is): call HTMLmap("inoremap", "" . g:html_map_entity_leader, g:html_map_entity_leader) if ! s:BoolVar('g:no_html_tab_mapping') " Allow hard tabs to be inserted: call HTMLmap("inoremap", "", "") call HTMLmap("nnoremap", "", "") " Tab takes us to a (hopefully) reasonable next insert point: call HTMLmap("inoremap", "", ":call HTMLnextInsertPoint('i')") call HTMLmap("nnoremap", "", ":call HTMLnextInsertPoint('n')") call HTMLmap("vnoremap", "", ":call HTMLnextInsertPoint('n')", -1) else call HTMLmap("inoremap", "", ":call HTMLnextInsertPoint('i')") call HTMLmap("nnoremap", "", ":call HTMLnextInsertPoint('n')") call HTMLmap("vnoremap", "", ":call HTMLnextInsertPoint('n')", -1) endif " Update an image tag's WIDTH & HEIGHT attributes (experimental!): runtime! MangleImageTag.vim if exists("*MangleImageTag") call HTMLmap("nnoremap", "mi", ":call MangleImageTag()") call HTMLmap("inoremap", "mi", ":call MangleImageTag()") endif call HTMLmap("nnoremap", "html", ":if HTMLtemplate() \\| startinsert \\| endif") " ---------------------------------------------------------------------------- " ---- General Markup Tag Mappings: ------------------------------------- {{{1 " SGML Doctype Command "call HTMLmap("nnoremap", "4", "1GO``") " SGML Doctype Command if ! s:BoolVar('b:do_xhtml_mappings') " Transitional HTML (Looser): call HTMLmap("nnoremap", "4", ":call append(0, '')") " Strict HTML: call HTMLmap("nnoremap", "s4", ":call append(0, '')") else " Transitional XHTML (Looser): call HTMLmap("nnoremap", "4", ":call append(0, '')") " Strict XHTML: call HTMLmap("nnoremap", "s4", ":call append(0, '')") endif call HTMLmap("imap", "4", "" . g:html_map_leader . "4") call HTMLmap("imap", "s4", "" . g:html_map_leader . "s4") " Content-Type META tag call HTMLmap("inoremap", "ct", "<[{META HTTP-EQUIV}]=\"Content-Type\" [{CONTENT}]=\"text/html; charset==DetectCharset()\" />") " Comment Tag call HTMLmap("inoremap", "cm", "=tag('comment','i')") " Visual mapping: call HTMLmap("vnoremap", "cm", ":execute \"normal \" . tag('comment','v')", 2) " Motion mapping: call HTMLmapo('cm', 0) " A HREF Anchor Hyperlink HTML 2.0 call HTMLmap("inoremap", "ah", "<[{A HREF=\"\">F\"") call HTMLmap("inoremap", "aH", "<[{A HREF=\"*\">F<") " Visual mappings: call HTMLmap("vnoremap", "ah", "`>a`<<[{A HREF}]=\"\">F\"", 0) call HTMLmap("vnoremap", "aH", "`>a\">`<<[{A HREF}]=\"f<", 0) " Motion mappings: call HTMLmapo('ah', 1) call HTMLmapo('aH', 1) " A HREF Anchor Hyperlink, with TARGET="" call HTMLmap("inoremap", "at", "<[{A HREF=\"\" TARGET=\"\">3F\"") call HTMLmap("inoremap", "aT", "<[{A HREF=\"*\" TARGET=\"\">F\"") " Visual mappings: call HTMLmap("vnoremap", "at", "`>a`<<[{A HREF=\"\" TARGET}]=\"\">3F\"", 0) call HTMLmap("vnoremap", "aT", "`>a\" [{TARGET=\"\">`<<[{A HREF}]=\"3f\"", 0) " Motion mappings: call HTMLmapo('at', 1) call HTMLmapo('aT', 1) " A NAME Named Anchor HTML 2.0 call HTMLmap("inoremap", "an", "<[{A NAME=\"\">F\"") call HTMLmap("inoremap", "aN", "<[{A NAME=\"*\">F<") " Visual mappings: call HTMLmap("vnoremap", "an", "`>a`<<[{A NAME}]=\"\">F\"", 0) call HTMLmap("vnoremap", "aN", "`>a\">`<<[{A NAME}]=\"f<", 0) " Motion mappings: call HTMLmapo('an', 1) call HTMLmapo('aN', 1) " ABBR Abbreviation HTML 4.0 call HTMLmap("inoremap", "ab", "<[{ABBR TITLE=\"\">F\"") call HTMLmap("inoremap", "aB", "<[{ABBR TITLE=\"*\">F<") " Visual mappings: call HTMLmap("vnoremap", "ab", "`>a`<<[{ABBR TITLE}]=\"\">F\"", 0) call HTMLmap("vnoremap", "aB", "`>a\">`<<[{ABBR TITLE}]=\"f<", 0) " Motion mappings: call HTMLmapo('ab', 1) call HTMLmapo('aB', 1) " ACRONYM HTML 4.0 call HTMLmap("inoremap", "ac", "<[{ACRONYM TITLE=\"\">F\"") call HTMLmap("inoremap", "aC", "<[{ACRONYM TITLE=\"*\">F<") " Visual mappings: call HTMLmap("vnoremap", "ac", "`>a`<<[{ACRONYM TITLE}]=\"\">F\"", 0) call HTMLmap("vnoremap", "aC", "`>a\">`<<[{ACRONYM TITLE}]=\"f<", 0) " Motion mappings: call HTMLmapo('ac', 1) call HTMLmapo('aC', 1) " ADDRESS HTML 2.0 call HTMLmap("inoremap", "ad", "<[{ADDRESS>F<") " Visual mapping: call HTMLmap("vnoremap", "ad", "`>a`<<[{ADDRESS}]>", 2) " Motion mapping: call HTMLmapo('ad', 0) " B Boldfaced Text HTML 2.0 call HTMLmap("inoremap", "bo", "=tag('b','i')") " Visual mapping: call HTMLmap("vnoremap", "bo", ":execute \"normal \" . tag('b','v')", 2) " Motion mapping: call HTMLmapo('bo', 0) " BASE HTML 2.0 HEADER call HTMLmap("inoremap", "bh", "<[{BASE HREF}]=\"\" />F\"") " Visual mapping: call HTMLmap("vnoremap", "bh", "`>a\" />`<<[{BASE HREF}]=\"", 2) " Motion mapping: call HTMLmapo('bh', 0) " BIG HTML 3.0 call HTMLmap("inoremap", "bi", "<[{BIG>F<") " Visual mapping: call HTMLmap("vnoremap", "bi", "`>a`<<[{BIG}]>") " Motion mapping: call HTMLmapo('bi', 0) " BLOCKQUOTE HTML 2.0 call HTMLmap("inoremap", "bl", "<[{BLOCKQUOTE}]>O") " Visual mapping: call HTMLmap("vnoremap", "bl", "`>a`<<[{BLOCKQUOTE}]>", 1) " Motion mapping: call HTMLmapo('bl', 0) " BODY HTML 2.0 call HTMLmap("inoremap", "bd", "<[{BODY}]>O") " Visual mapping: call HTMLmap("vnoremap", "bd", "`>a`<<[{BODY}]>", 1) " Motion mapping: call HTMLmapo('bd', 0) " BR Line break HTML 2.0 call HTMLmap("inoremap", "br", "<[{BR}] />") " CENTER NETSCAPE call HTMLmap("inoremap", "ce", "<[{CENTER>F<") " Visual mapping: call HTMLmap("vnoremap", "ce", "`>a`<<[{CENTER}]>", 2) " Motion mapping: call HTMLmapo('ce', 0) " CITE HTML 2.0 call HTMLmap("inoremap", "ci", "<[{CITE>F<") " Visual mapping: call HTMLmap("vnoremap", "ci", "`>a`<<[{CITE}]>", 2) " Motion mapping: call HTMLmapo('ci', 0) " CODE HTML 2.0 call HTMLmap("inoremap", "co", "<[{CODE>F<") " Visual mapping: call HTMLmap("vnoremap", "co", "`>a`<<[{CODE}]>", 2) " Motion mapping: call HTMLmapo('co', 0) " DEFINITION LIST COMPONENTS HTML 2.0 " DL Definition List " DT Definition Term " DD Definition Body call HTMLmap("inoremap", "dl", "<[{DL}]>O") call HTMLmap("inoremap", "dt", "<[{DT}]>F<") call HTMLmap("inoremap", "dd", "<[{DD}]>F<") " Visual mappings: call HTMLmap("vnoremap", "dl", "`>a`<<[{DL}]>", 1) call HTMLmap("vnoremap", "dt", "`>a`<<[{DT}]>", 2) call HTMLmap("vnoremap", "dd", "`>a`<<[{DD}]>", 2) " Motion mapping: call HTMLmapo('dl', 0) call HTMLmapo('dt', 0) call HTMLmapo('dd', 0) " DEL Deleted Text HTML 3.0 call HTMLmap("inoremap", "de", "[{DEL>F<") " Visual mapping: call HTMLmap("vnoremap", "de", "`>a`<[{DEL}]>") " Motion mapping: call HTMLmapo('de', 0) " DFN Defining Instance HTML 3.0 call HTMLmap("inoremap", "df", "<[{DFN>F<") " Visual mapping: call HTMLmap("vnoremap", "df", "`>a`<<[{DFN}]>", 2) " Motion mapping: call HTMLmapo('df', 0) " DIV Document Division HTML 3.0 call HTMLmap("inoremap", "dv", "<[{DIV}]>O") " Visual mapping: call HTMLmap("vnoremap", "dv", "`>a`<<[{DIV}]>", 1) " Motion mapping: call HTMLmapo('dv', 0) " SPAN Delimit Arbitrary Text HTML 4.0 call HTMLmap("inoremap", "sn", "<[{SPAN>F<") " Visual mapping: call HTMLmap("vnoremap", "sn", "`>a`<<[{SPAN}]>", 2) " Motion mapping: call HTMLmapo('sn', 0) " EM Emphasize HTML 2.0 call HTMLmap("inoremap", "em", "=tag('em','i')") " Visual mapping: call HTMLmap("vnoremap", "em", ":execute \"normal \" . tag('em','v')", 2) " Motion mapping: call HTMLmapo('em', 0) " FONT NETSCAPE call HTMLmap("inoremap", "fo", "<[{FONT SIZE=\"\">F\"") call HTMLmap("inoremap", "fc", "<[{FONT COLOR=\"\">F\"") " Visual mappings: call HTMLmap("vnoremap", "fo", "`>a`<<[{FONT SIZE}]=\"\">F\"", 0) call HTMLmap("vnoremap", "fc", "`>a`<<[{FONT COLOR}]=\"\">F\"", 0) " Motion mappings: call HTMLmapo('fo', 1) call HTMLmapo('fc', 1) " HEADERS, LEVELS 1-6 HTML 2.0 call HTMLmap("inoremap", "h1", "<[{H1}]>F<") call HTMLmap("inoremap", "h2", "<[{H2}]>F<") call HTMLmap("inoremap", "h3", "<[{H3}]>F<") call HTMLmap("inoremap", "h4", "<[{H4}]>F<") call HTMLmap("inoremap", "h5", "<[{H5}]>F<") call HTMLmap("inoremap", "h6", "<[{H6}]>F<") call HTMLmap("inoremap", "H1", "<[{H1 ALIGN=\"CENTER}]\">F<") call HTMLmap("inoremap", "H2", "<[{H2 ALIGN=\"CENTER}]\">F<") call HTMLmap("inoremap", "H3", "<[{H3 ALIGN=\"CENTER}]\">F<") call HTMLmap("inoremap", "H4", "<[{H4 ALIGN=\"CENTER}]\">F<") call HTMLmap("inoremap", "H5", "<[{H5 ALIGN=\"CENTER}]\">F<") call HTMLmap("inoremap", "H6", "<[{H6 ALIGN=\"CENTER}]\">F<") " Visual mappings: call HTMLmap("vnoremap", "h1", "`>a`<<[{H1}]>", 2) call HTMLmap("vnoremap", "h2", "`>a`<<[{H2}]>", 2) call HTMLmap("vnoremap", "h3", "`>a`<<[{H3}]>", 2) call HTMLmap("vnoremap", "h4", "`>a`<<[{H4}]>", 2) call HTMLmap("vnoremap", "h5", "`>a`<<[{H5}]>", 2) call HTMLmap("vnoremap", "h6", "`>a`<<[{H6}]>", 2) call HTMLmap("vnoremap", "H1", "`>a`<<[{H1 ALIGN=\"CENTER}]\">", 2) call HTMLmap("vnoremap", "H2", "`>a`<<[{H2 ALIGN=\"CENTER}]\">", 2) call HTMLmap("vnoremap", "H3", "`>a`<<[{H3 ALIGN=\"CENTER}]\">", 2) call HTMLmap("vnoremap", "H4", "`>a`<<[{H4 ALIGN=\"CENTER}]\">", 2) call HTMLmap("vnoremap", "H5", "`>a`<<[{H5 ALIGN=\"CENTER}]\">", 2) call HTMLmap("vnoremap", "H6", "`>a`<<[{H6 ALIGN=\"CENTER}]\">", 2) " Motion mappings: call HTMLmapo("h1", 0) call HTMLmapo("h2", 0) call HTMLmapo("h3", 0) call HTMLmapo("h4", 0) call HTMLmapo("h5", 0) call HTMLmapo("h6", 0) call HTMLmapo("H1", 0) call HTMLmapo("H2", 0) call HTMLmapo("H3", 0) call HTMLmapo("H4", 0) call HTMLmapo("H5", 0) call HTMLmapo("H6", 0) " HEAD HTML 2.0 call HTMLmap("inoremap", "he", "<[{HEAD}]>O") " Visual mapping: call HTMLmap("vnoremap", "he", "`>a`<<[{HEAD}]>", 1) " Motion mapping: call HTMLmapo('he', 0) " HR Horizontal Rule HTML 2.0 W/NETSCAPISM call HTMLmap("inoremap", "hr", "<[{HR}] />") " HR Horizontal Rule HTML 2.0 W/NETSCAPISM cal