" ===================================================================
" HTML - HTML - HTML - HTML - HTML - HTML - HTML - HTML
" ===================================================================
"
" File: $HOME/vim/src/html.vim
" This file: <URL:http://www.math.fu-berlin.de/~guckes/vim/src/html.vim>
" Purpose: Setup file for the editor Vim for Webpage/HTML editing
" Author: Sven Guckes guckes@vim.org (guckes@math.fu-berlin.de)
" <URL:http://www.math.fu-berlin.de/~guckes/>
" Comments: See also: <URL:http://www.vim.org/html.html>
" Please send comments to me - email preferred!
" Last update: Tue May 19 18:00:00 CEST 1998
"
" HTML = HyperText Markup Language - the language of the World Wide Web
"
" ===================================================================
" HTML - working on files
" ===================================================================
"
" Whenever I edit a web page I use ",e" to start the edit command.
" And I use ",rn" to read in a web page template:
" ,e = edit www file
nmap ,e :e ~/.P/
" NOTE: The directory ~/.P is a link to the directory with my webpages.
" the name is short so it will be short for the output of ":ls".
"
" I used ",e" for the command here before, but this was part of the
" default string for "highlight", so while entering the default
" string the ",e" it got expanded. Darn!
"
" ,rm = read mailto (standard html file for a mailto link to my address)
" map ,rm :r ~/.P/txt/mailto.html
"
" ,rn = read new-page (standard html file for a new web page)
" see http://www.math.fu-berlin.de/~guckes/txt/New.page.form.html
map ,rn :0r ~/.P/txt/New.page.form.html
"
" ,p = make current file public readable
nmap ,p :!chmod 644 %<CR>
"
" ===================================================================
" HTML - reading in the current date
" ===================================================================
"
" First, some command to add date stamps (with and without time).
" I do these manually whenever I feel them necessary.
"
" iab Ydate <C-R>=strftime("%y%m%d")<CR>
" Example: 971027
"
iab Ytime <C-R>=strftime("%H:%M")<CR>
" Example: 14:28
"
iab YDT <C-R>=strftime("%y%m%d %T")<CR>
" Example: 971027 12:00:00
"
iab YDATE <C-R>=strftime("%a %b %d %T %Z %Y")<CR>
" Example: Tue Dec 16 12:07:00 CET 1997
"
" ,L = "Last updated" - replace old time stamp with a new one
" preserving whitespace and using internal "strftime" command:
" requires the abbreviation "YDATE"
map ,L 1G/Last update:\s*/e+1<CR>CYDATE<ESC>
" Example:
" before: "Last update: Thu Apr 6 12:07:00 CET 1967"
" after: "Last update: Tue Dec 16 12:07:00 CET 1997"
"
" ,L = "Last updated" - replace old time stamp with a new one
" using external "date" command (not good for all systems):
" map ,L 1G/Last update: */e+1<CR>D:r!date<CR>kJ
"
" ===================================================================
" HTML - Inserting "single" tags
" ===================================================================
"
iab Ybr <BR>
iab Yhr <HR>
iab Yp <P>
"
" ===================================================================
" HTML - making environments
" ===================================================================
"
" HTML - make current word an HTML environment
map ,me yapa></<ESC>Ea><ESC>Bi<<ESC>/><<CR>
"
" ===================================================================
" HTML - inserting environments
" ===================================================================
"
" Comment:
iab Ycom <!--X--><ESC>FXs
vmap ,com v`<i<!--<ESC>`>i--><ESC>
"
" ===================================================================
" HTML - changing the appearance/font of text
" ===================================================================
"
" BlockQuoted Text:
iab Ybl <BLOCKQUOTE></BLOCKQUOTE><ESC>T>i
" vmap ,bl "zdi<BLOCKQUOTE><C-R>z</BLOCKQUOTE><ESC>2F>
"
" Bold text:
iab Yb <B></B><ESC>T>i
vmap ,b "zdi<B><C-R>z</B><ESC>2F>
"
" Centered Text:
iab Ycen <CENTER></CENTER><ESC>T>i
vmap ,cen "zdi<CENTER><C-M><C-R>z<C-M></CENTER><ESC>T>i
"
" Code in Text:
iab Ycod <CODE></CODE><ESC>T>i
vmap ,cod "zdi<CODE><C-M><C-R>z<C-M></CODE><C-M><ESC>T>i
"
" Italic Text:
iab Yi <I></I><ESC>T>i
vmap ,i "zdi<I><C-R>z</I><ESC>T>
"
" Typewriter Type:
iab Ytt <TT></TT><ESC>T>i
vmap ,tt "zdi<TT><C-R>z</TT><ESC>T>
"
" ===================================================================
" HTML - Preserving Text Structure
" ===================================================================
"
" Preserve Text Formatting *with* interpretation of HTML:
iab Ypre <PRE></PRE><ESC>T>i
" vmap ,pre "zdi<pre><C-M><C-R>z</pre><C-M><ESC>T>
vmap ,pre mz:<ESC>'<O<PRE><ESC>'>o</PRE><ESC>`z
"
" Preserve Text Formatting without interpretation of HTML:
" Insert environment <xmp></xmp>
iab Yxmp <XMP></XMP><ESC>T>i
" vmap ,xmp "zdi<XMP><C-M><C-R>z<C-M></XMP><C-M><ESC>T>i
vmap ,xmp mz:<ESC>'<O<XMP><ESC>'>o</XMP><ESC>`z
"
" ===================================================================
" HTML - Making Tables
" ===================================================================
"
" Table Data
iab Ytd <TD></TD><ESC>T>i
vmap ,td "zdi<TD><C-R>z</TD><ESC>T>i
" Table Row
iab Ytr <TR></TR><ESC>T>i
vmap ,tr "zdi<TR><C-R>z</TR><ESC>T>i
"
"
" ===================================================================
" HTML - Making Header Lines (h1 to h6)
" ===================================================================
"
iab Yh1 <H1></H1><ESC>T>i
vmap ,h1 "zdi<H1><C-R>z</H1><ESC>2F>
iab Yh2 <H2></H2><ESC>T>i
vmap ,h2 "zdi<h2><C-R>z</H2><ESC>2F>
iab Yh3 <H3></H3><ESC>T>i
vmap ,h3 "zdi<H3><C-R>z</H3><ESC>2F>
iab Yh4 <H4></H4><ESC>T>i
vmap ,h4 "zdi<H4><C-R>z</H4><ESC>2F>
iab Yh5 <H5></H5><ESC>T>i
vmap ,h5 "zdi<H5><C-R>z</H5><ESC>2F>
iab Yh6 <H6></H6><ESC>T>i
vmap ,h6 "zdi<H6><C-R>z</H6><ESC>2F>
"
" ===================================================================
" HTML - Making Lists and List Items
" ===================================================================
"
" Insert "ordered list" with one list element
iab Yol <OL><CR><LI><CR></OL><ESC>k
" Insert "unordered list" with one list element
iab Yul <UL><CR><LI><CR></UL><ESC>k
" Insert "decsription list" with one list element
" iab Ydl <dl><CR><dt><CR><dd><CR><p><CR></dl><CR><ESC>4kA
iab Ydl <DL><CR><CR><DT><CR><DD><CR><p><CR><CR></DL><CR><ESC>5kA
"
" Insert "list" item (for both ordered and unordered list)
iab Yli <LI>
" Insert "description list" item
iab Ydt <DT><CR><DD><CR><P><CR><ESC>kA
iab Ydp <DT><CR><DD><C-M><P><C-M><ESC>kkkA
"
" ===================================================================
" HTML - Making Links
" ===================================================================
"
"
" A HREF (HTML 2.0)
iab Yhref <A HREF=""></A><ESC>?""<CR>a
vmap ,href "zdi<a href=""><C-R>z</a><ESC>F"i
iab Ylink <A HREF=""></A><ESC>?""<CR>a
vmap ,link "zdi<A HREF="<C-R>z"<C-M><C-I>><C-R>z</A><ESC>F"i
"
" A NAME (HTML-2.0)
iab Yname <A NAME=""></a><ESC>?""<CR>a
vmap ,name "zdi<A NAME="<C-R>z"<C-M><C-I>><C-R>z</A><ESC>2F>
"
" Insert/make link to image
iab Yimg <IMG ALT="[]"<C-M> ALIGN=<C-M> SRC=""></A><ESC>?""<CR>a
"
" Insert/make mailto link
iab Ymail <A HREF="mailto:"></A><ESC>?:<CR>a
vmap ,mail "zdi<A HREF="mailto:<C-R>z"<C-M><C-I><C-I>><C-R>z</A><ESC>2F>
vmap ,Mail "zdi<A HREF="mailto:<C-R>z"><C-R>z</A><ESC>2F>
"
" Insert/make link to newsgroup
iab Ynews <A HREF="news:"></A><ESC>?:<CR>a
vmap ,news "zdi<A HREF="news:<C-R>z"><C-R>z</A><ESC>2F>
"
" Ypage Insert page description with a possible link and text
iab Ypage <C-M>page:<C-I><C-M>link:<C-I><C-M>text:<C-I><ESC>kkA
"
"
" For adding descriptions and keywords to important pages:
" <META Name="description" Content="Write your description here">
" <META Name="keywords" Content="Write your keywords here">
"
" Colorizing Text
"
" ,Cblu = colorize the selection with color "blue"
vmap ,Cblu "zdi<FONT COLOR="#0000FF"><C-R>z</FONT>
" ,Cgre = colorize the selection with color "green"
vmap ,Cgre "zdi<FONT COLOR="#00FF00"><C-R>z</FONT>
" ,Cred = colorize the selection with color "red"
vmap ,Cred "zdi<FONT COLOR="#FF0000"><C-R>z</FONT>
"
" ===================================================================
" HTML - handling special text
" ===================================================================
"
" HTML - inserting special characters
imap ;& &
imap ;K ©
imap ;" "
imap ;< <
imap ;> >
"
" ,= = turn "===" into headline of size 1
nmap ,= :%s/^===\(.*\)$/<H1>\1<\/H1>/c<CR>
" Example:
" before: === New section
" after: <H1>New section</H1>
"
" ===================================================================
" HTML 3.0
" ===================================================================
" environments:
" ABBREV ACRONYM AU BANNER BIG BQ CAPTION CREDIT DEL DFN DIR DIV FN
" HTML INS NOTE OL P Q S SMALL SUB SUP TAB V
" other:
" FIG LANG OVERLAY RANGE SPOT STYLE
"
" ===================================================================
" HTML - Misc
" ===================================================================
"
" HTML - Add closing tags to name tag
" (which I forgot when I started HTML):
" map ,,,, :g/^<a name="[a-z_]*">$/s/$/<\/a>/
" Example:
" before: <a name="close_tag">
" after: <a name="close_tag"></a>
"
" Insert/make reference link to overview list (short"cut")
iab Ycut \| <a href="#"<C-I>></a><ESC>F#a
vmap ,cut "zdi<a href="#<C-R>z"<C-I>><C-R>z</a><ESC>2F>
"
" enf of file