" HTML.vim - Macros, menus, and autocommands for html mode
"
" OVERVIEW
" This file has three parts:
" SECTION 1: Setup of menus and associated macros
" SECTION 2: Setup of macros unassociated with menus
" SECTION 3: Additional autocommands
"
" My main interest here was creating some syntax specific menus (starting
" with HTML) for gvim. Besides helping the novice, the menus are a quick
" way to view what some of the macros are assigned to. Macros and keyboard
" mappings are only active in buffers editing HTML files. Two main menus
" are created - one for HTML tags (with submenus), and another for tools.
" The tools menu can be configured to call some validations tools, for
" example - TODO.
"
" Originally, I was using Alt-Key sequences for my bindings (e.g.
" was bound to the insert comment macro). I quickly ran out of letters,
" so I think the ;xx plan works better.
"
" I also fully specified mappings and menus for each of the 4 modes:
" normal, visual, insert, and command. This might be overkill, but I
" found it useful to have minor differences in each of the macros. The
" utility of command mode mappings is particularly questionalble.
"
" I also added an autocommand to read a user's HTML template file when
" editing a nonexistant html file. Also, when writing the buffer, a
" BufWritePost autocommand calls an open netscape to view the results.
" See notes on this below.
"
" BUGS, SUGGESTIONS, and COPYRIGHT
"
" These macros may be freely copied and modified. If you find bugs, or
" if have some suggestions, or if you find them useful, I'd appreciate
" hearing about it.
"
" T Scott Urban
" urban@unix.mauigateway.com
"
" CREDITS
" I took a lot of these macros from Doug _____ (drenze@avalon.net).
" I found his work at http://www.grafnetix.com/~laurent/vim/html.mac
" with some modifications by Ives Aerts (ives@sonytel.be).
"
"
"
"
" SECTION 1: Setup menus and associated mapped keyboard shortcuts
"
"" Menu HTML Tags
"
""" Comment:
" normal new comment on previous line
" visual wrap visual selection in comment
" insert insert comment at cursor position
if has("gui")
nmenu HTML\ Tags.Comment\ \ \ \ \ ;cm O2bcw
vmenu HTML\ Tags.Comment\ \ \ \ \ ;cm `>a -->`
imenu HTML\ Tags.Comment\ \ \ \ \ ;cm 2bcw
endif
nmap ;cm Obbcw
vmap ;cm `>a -->`
imap ;cm 2bcw
"
""" Name Anchor:
" normal creates name anchor on previous line
" visual wrap name anchor around current visual selection
" insert insert name anchor at cursor position
if has("gui")
nmenu HTML\ Tags.Name\ Anchor\ ;an O2bcw
vmenu HTML\ Tags.Name\ Anchor\ ;an `>a">`2bcw
endif
nmap ;an O2bcw
vmap ;an `>a">`2bcw
"
""" Href Anchor:
" normal creates href anchor on previous line
" visual wraps href anchor around current visual selection
" insert inserts href anchor at cursor position
if has("gui")
nmenu HTML\ Tags.Href\ Anchor\ ;ah OTAG5bcw
vmenu HTML\ Tags.Href\ Anchor\ ;ah `>a`2bcw
imenu HTML\ Tags.Href\ Anchor\ ;ah TAG5bcw
endif
nmap ;ah OTAG5bcw
vmap ;ah `>a`2bcw
imap ;ah TAG5bcw
"
""" Image:
" normal creates image on previous line
" visual creates image around current visual selection ??
" insert inserts image at cursor position
"
" if you don't like the alt tag, remove it. Just trying to
" enforce good style ;>
if has("gui")
nmenu HTML\ Tags.Image\ \ \ \ \ \ \ ;im O6bcw
vmenu HTML\ Tags.Image\ \ \ \ \ \ \ ;im `>a" alt="IMAGE">`6bcw
endif
nmap ;im O6bcw
vmap ;im `>a" alt="IMAGE">`6bcw
"
""" Break:
" normal creates break on previous line
" visual creates break before selection
" insert inserts break at cursor
if has("gui")
nmenu HTML\ Tags.Break\ \ \ \ \ \ \ ;br O
vmenu HTML\ Tags.Break\ \ \ \ \ \ \ ;br `
imenu HTML\ Tags.Break\ \ \ \ \ \ \ ;br
endif
nmap ;br O
vmap ;br `
imap ;br
"
""" Horizontal Rule:
" normal creates rule on previous line
" visual inserts rule before selection
" insert inserts rule at cursor
if has("gui")
nmenu HTML\ Tags.Rule\ \ \ \ \ \ \ \ ;hr O
vmenu HTML\ Tags.Rule\ \ \ \ \ \ \ \ ;hr `
imenu HTML\ Tags.Rule\ \ \ \ \ \ \ \ ;hr
endif
nmap ;hr O
vmap ;hr `
imap ;hr
"
""" Headings Sub-Menu
" normal creates selected heading on previous line
" visual creates selected heading around visual selection
" insert inserts selected heading at cursor position
"
"""" H1 Heading
if has("gui")
nmenu HTML\ Tags.Headings.H1\ \ ;h1 OHEADING
3bcw
vmenu HTML\ Tags.Headings.H1\ \ ;h1 `>a`l
imenu HTML\ Tags.Headings.H1\ \ ;h1 HEADING
3bcw
endif
nmap ;h1 OHEADING
3bcw
vmap ;h1 `>a`l
imap ;h1 HEADING
3bcw
"
"""" H2 Heading
if has("gui")
nmenu HTML\ Tags.Headings.H2\ \ ;h2 OHEADING
3bcw
vmenu HTML\ Tags.Headings.H2\ \ ;h2 `>a`l
imenu HTML\ Tags.Headings.H2\ \ ;h2 HEADING
3bcw
endif
nmap ;h2 OHEADING
3bcw
vmap ;h2 `>a`l
imap ;h2 HEADING
3bcw
"
"""" H3 Heading
if has("gui")
nmenu HTML\ Tags.Headings.H3\ \ ;h3 OHEADING
3bcw
vmenu HTML\ Tags.Headings.H3\ \ ;h3 `>a`l
imenu HTML\ Tags.Headings.H3\ \ ;h3 HEADING
3bcw
endif
nmap ;h3 OHEADING
3bcw
vmap ;h3 `>a`l
imap ;h3 HEADING
3bcw
"
"""" H4 Heading
if has("gui")
nmenu HTML\ Tags.Headings.H4\ \ ;h4 OHEADING
3bcw
vmenu HTML\ Tags.Headings.H4\ \ ;h4 `>a`l
imenu HTML\ Tags.Headings.H4\ \ ;h4 HEADING
3bcw
endif
nmap ;h4 OHEADING
3bcw
vmap ;h4 `>a`l
imap ;h4 HEADING
3bcw
"
"""" H5 Heading
if has("gui")
nmenu HTML\ Tags.Headings.H5\ \ ;h5 OHEADING
3bcw
vmenu HTML\ Tags.Headings.H5\ \ ;h5 `>a`l
imenu HTML\ Tags.Headings.H5\ \ ;h5 HEADING
3bcw
endif
nmap ;h5 OHEADING
3bcw
vmap ;h5 `>a`l
imap ;h5 HEADING
3bcw
"
"""" H6 Heading
if has("gui")
nmenu HTML\ Tags.Headings.H6\ \ ;h6 OHEADING
3bcw
vmenu HTML\ Tags.Headings.H6\ \ ;h6 `>a`l
imenu HTML\ Tags.Headings.H6\ \ ;h6 HEADING
3bcw
endif
nmap ;h6 OHEADING
3bcw
vmap ;h6 `>a`l
imap ;h6 HEADING
3bcw
"
""" Format:
" normal creates selected format on previous line
" visual creates selected format around visual selection
" insert creates selected format at cursor position
"
" Address format
if has("gui")
nmenu HTML\ Tags.Formats.Address\ \ \ \ \ ;ad OTEXT3bcw
vmenu HTML\ Tags.Formats.Address\ \ \ \ \ ;ad `>a`l
imenu HTML\ Tags.Formats.Address\ \ \ \ \ ;ad TEXT3bcw
endif
nmap ;ad OTEXT3bcw
vmap ;ad `>a`l
imap ;ad TEXT3bcw
"
" Bold format
if has("gui")
nmenu HTML\ Tags.Formats.Bold\ \ \ \ \ \ \ \ ;bo OTEXT3bcw
vmenu HTML\ Tags.Formats.Bold\ \ \ \ \ \ \ \ ;bo `>a`l
imenu HTML\ Tags.Formats.Bold\ \ \ \ \ \ \ \ ;bo TEXT3bcw
endif
nmap ;bo OTEXT3bcw
vmap ;bo `>a`l
imap ;bo TEXT3bcw
"
" Big format
if has("gui")
nmenu HTML\ Tags.Formats.Bigger\ \ \ \ \ \ ;bi OTEXT3bcw
vmenu HTML\ Tags.Formats.Bigger\ \ \ \ \ \ ;bi `>a`l
imenu HTML\ Tags.Formats.Bigger\ \ \ \ \ \ ;bi TEXT3bcw
endif
nmap ;bi OTEXT3bcw
vmap ;bi `>a`l
imap ;bi TEXT3bcw
"
" Blink format - you might take this out to discourage use
if has("gui")
nmenu HTML\ Tags.Formats.Blink\ \ \ \ \ \ \ ;bk O3bcw
vmenu HTML\ Tags.Formats.Blink\ \ \ \ \ \ \ ;bk `>a`l
imenu HTML\ Tags.Formats.Blink\ \ \ \ \ \ \ ;bk 3bcw
endif
nmap ;bk O3bcw
vmap ;bk `>a`l
imap ;bk 3bcw
"
" Blockquote format
if has("gui")
nmenu HTML\ Tags.Formats.Blockquote\ \ ;bl OTEXT
3bcw
vmenu HTML\ Tags.Formats.Blockquote\ \ ;bl `>a`l
imenu HTML\ Tags.Formats.Blockquote\ \ ;bl TEXT
3bcw
endif
nmap ;bl OTEXT
3bcw
vmap ;bl `>a`l
imap ;bl TEXT
3bcw
"
" Center format
if has("gui")
nmenu HTML\ Tags.Formats.Center\ \ \ \ \ \ ;ce OTEXT3bcw
vmenu HTML\ Tags.Formats.Center\ \ \ \ \ \ ;ce `>a`l
imenu HTML\ Tags.Formats.Center\ \ \ \ \ \ ;ce TEXT3bcw
endif
nmap ;ce OTEXT3bcw
vmap ;ce `>a`l
imap ;ce TEXT3bcw
"
" Cite format
if has("gui")
nmenu HTML\ Tags.Formats.Cite\ \ \ \ \ \ \ \ ;ci OTEXT3bcw
vmenu HTML\ Tags.Formats.Cite\ \ \ \ \ \ \ \ ;ci `>a`l
imenu HTML\ Tags.Formats.Cite\ \ \ \ \ \ \ \ ;ci TEXT3bcw
endif
nmap ;ci OTEXT3bcw
vmap ;ci `>a`l
imap ;ci TEXT3bcw
"
" Code format
if has("gui")
nmenu HTML\ Tags.Formats.Code\ \ \ \ \ \ \ \ ;co OTEXT
3bcw
vmenu HTML\ Tags.Formats.Code\ \ \ \ \ \ \ \ ;co `>a`l
imenu HTML\ Tags.Formats.Code\ \ \ \ \ \ \ \ ;co TEXT
3bcw
endif
nmap ;co OTEXT
3bcw
vmap ;co `>a`l
imap ;co TEXT
3bcw
"
" Definition format
if has("gui")
nmenu HTML\ Tags.Formats.Definition\ \ ;df OTEXT3bcw
vmenu HTML\ Tags.Formats.Definition\ \ ;df `>a`l
imenu HTML\ Tags.Formats.Definition\ \ ;df TEXT3bcw
endif
nmap ;df OTEXT3bcw
vmap ;df `>a`l
imap ;df TEXT3bcw
"
" Emphasis format
if has("gui")
nmenu HTML\ Tags.Formats.Emphasis\ \ \ \ ;em OTEXT3bcw
vmenu HTML\ Tags.Formats.Emphasis\ \ \ \ ;em `>a`l
imenu HTML\ Tags.Formats.Emphasis\ \ \ \ ;em TEXT3bcw
endif
nmap ;em OTEXT3bcw
vmap ;em `>a`l
imap ;em TEXT3bcw
"
" Italics format
if has("gui")
nmenu HTML\ Tags.Formats.Italics\ \ \ \ \ ;it OTEXT3bcw
vmenu HTML\ Tags.Formats.Italics\ \ \ \ \ ;it `>a`l
imenu HTML\ Tags.Formats.Italics\ \ \ \ \ ;it TEXT3bcw
endif
nmap ;it OTEXT3bcw
vmap ;it `>a`l
imap ;it TEXT3bcw
"
" Keyboard format
if has("gui")
nmenu HTML\ Tags.Formats.Keyboard\ \ \ \ ;kb OTEXT3bcw
vmenu HTML\ Tags.Formats.Keyboard\ \ \ \ ;kb `>a`l
imenu HTML\ Tags.Formats.Keyboard\ \ \ \ ;kb TEXT3bcw
endif
nmap ;kb OTEXT3bcw
vmap ;kb `>a`l
imap ;kb TEXT3bcw
"
" No break format
if has("gui")
nmenu HTML\ Tags.Formats.No\ Break\ \ \ \ ;nb OTEXT3bcw
vmenu HTML\ Tags.Formats.No\ Break\ \ \ \ ;nb `>a