sponsor Vim development Vim logo Vim Book Ad

HTML/XHTML Macros : HTML/XHTML editing macros and menus

 script karma  Rating 439/159, Downloaded by 19512  Comments, bugs, improvements  Vim wiki

created by
Christian J. Robinson
script type
This is a set of HTML/XHTML mappings and menus for Vim 9 or later. The mappings will be local to the buffer so they won't interfere if you edit other files in the same Vim session.

The macros automatically insert a tag and position the cursor at the logical insert point.  For example, in insert the mapping ";ah" inserts <A HREF=""></A> and leaves the cursor between the double quotes.  If you were to visually highlight some text then type ";ah" it would wrap the tag around the text.  For example:
        some text
        <A HREF="">some text</A>
With the cursor positioned between the double quotes in insert mode. Or if you used ";aH" instead:
        <A HREF="some text"></A>
With the cursor positioned between the > and the < in insert mode.

There are many other features, such as a configurable template inserted with the ";html" normal mode macro, browser remote control mappings, etc.

See https://christianrobinson.name/assets/programming/faq.html for frequently asked questions.

See https://christianrobinson.name/assets/programming/HTML.html to preview the help file.
install details
Note: If you have an old installation of this plugin, you need to remove its files first or they may prevent the packed version from loading.

Put ":filetype plugin on" in your vimrc, then extract HTML.zip in your runtime directory (~/.vim for Unix, %USERPROFILE%\vimfiles for Windows; see ":help 'runtimepath'").

Alternatively you may use git. See: https://github.com/Heptite/HTML

See https://christianrobinson.name/HTML for more information, newer versions, and extra files.

rate this script Life Changing Helpful Unfulfilling 
script versions (upload new version)

Click on the package to download.

package script version date Vim version user release notes
HTML.zip 1.3.0 2022-07-27 9.0 Christian J. Robinson - Refactoring
- Change logic for handling visual mappings
HTML.zip 1.2.5 2022-07-07 9.0 Christian J. Robinson - Fix :HTMLabout, plus documentation fixes (Ivan Pešić)
- Try catching some errors to prevent aborting of mappings which could cause options to be unset
HTML.zip 1.2.4 2022-06-29 9.0 Christian J. Robinson - Update minimum Vim version requirement to 9.0 now that Vim9 has been released
HTML.zip 1.2.3 2022-02-28 9.0 Christian J. Robinson - Fix character entity conversion mappings
HTML.zip 1.2.2 2022-02-03 9.0 Christian J. Robinson - Update to latest Vim9 syntax
- Try to fix visual mapping issues
HTML.zip 1.2.1 2022-01-19 9.0 Christian J. Robinson - Small update with tweaks and to reflect the new vim9script syntax
HTML.zip 1.2.0 2022-01-16 9.0 Christian J. Robinson - More refactoring
- Under the hood optimizations
HTML.zip 1.1.16 2022-01-07 9.0 Christian J. Robinson - Update to use Vim9's revised import syntax
HTML.zip 1.1.15 2021-09-26 9.0 Christian J. Robinson - Tweaks, and speed improvements
- Some plugin commands are now local to the buffer
HTML.zip 1.1.14 2021-09-03 9.0 Christian J. Robinson - Support Brave browser
- Image tag WIDTHxHEIGHT updater now supports a couple more image types
HTML.zip 1.1.13 2021-08-30 9.0 Christian J. Robinson - Some bugs fixed
- Some refactoring
- Minor feature additions
HTML.zip 1.1.11 2021-08-22 9.0 Christian J. Robinson - Fixed a bug that crept in while trying to fix other bugs.
- Code tweaks.
HTML.zip 1.1.10 2021-08-18 9.0 Christian J. Robinson - Fix more bugs.
- Simplify some code.
HTML.zip 1.1.9 2021-08-16 9.0 Christian J. Robinson - Loading bug fixed.
- More entities.
- Moved config variables to a unified dictionary.
HTML.zip 1.1.8 2021-08-14 9.0 Christian J. Robinson - More bugs were found and squashed.
- Moved more data to json.
HTML.zip 1.1.7 2021-08-13 9.0 Christian J. Robinson - Some bugs crept in during the change over to json.
- Code improvements.
HTML.zip 1.1.6 2021-08-12 9.0 Christian J. Robinson - Fixed a serious bug loading the entities.
- Also load the tag mappings and menus via json.
HTML.zip 1.1.5 2021-08-11 9.0 Christian J. Robinson - Remove unused code.
- Make defining HTML entities with menus easier.
- Add an about command.
HTML.zip 1.1.4 2021-08-10 9.0 Christian J. Robinson - Separate constants to another file
- Rewrote the color selector code to use Vim's popups
- Other small changes
HTML.zip 1.1.3 2021-08-07 9.0 Christian J. Robinson - Allow switching between upper and lowercase tags.
- Fix menu handling bug.
HTML.zip 1.1.2 2021-08-06 9.0 Christian J. Robinson - Config option to allow the menu to be placed in another menu.
- Add more documentation tags.
HTML.zip 1.1.1 2021-08-04 9.0 Christian J. Robinson - More smart tags
- More bug fixes
- Overhaul some more code
HTML.zip 1.1.0 2021-08-01 9.0 Christian J. Robinson - Overhaul smart tag code, allowing many more tags to be "smart"
- Optimizations
- Documentation updates
HTML.zip 1.0.18 2021-07-30 9.0 Christian J. Robinson - Bug fixes
- Improve code for flexibility
- ;mi mapping now works in more contexts
HTML.zip 1.0.17 2021-07-28 9.0 Christian J. Robinson - Bug fixes and many code improvements
HTML.zip 1.0.16 2021-07-27 9.0 Christian J. Robinson - Better character entity conversion.
- Bug fixes.
HTML.zip 1.0.14 2021-07-24 9.0 Christian J. Robinson - Add "links" to available textmode browsers
- Use system menu.vim ToolBar items where applicable
- More refactoring and internal code improvements
- Bug fixes
HTML.zip 1.0.11 2021-07-21 9.0 Christian J. Robinson - Allow lynx and w3m to be opened in a :terminal
- Now available on github
HTML.zip 1.0.8 2021-07-18 9.0 Christian J. Robinson Some refactoring and logic changes, very little in the way of feature additions
HTML.zip 1.0.5 2020-11-09 9.0 Christian J. Robinson - Support more tags, including Server-Side Includes
- Many tweaks and bug fixes
HTML.zip 1.0.0 2020-10-22 9.0 Christian J. Robinson - Major refactor, now only supports Vim 9 (or a very recently patched version of Vim 8 if you have it)
HTML.zip 0.44.4 2020-10-14 8.2 Christian J. Robinson - Bug fixes
HTML.zip 0.44.3 2020-10-11 8.2 Christian J. Robinson - Transition to Vim 8.2 and begin transition to the upcoming Vim 9.0
HTML.zip 0.42.6 2020-02-21 7.2 Christian J. Robinson - Add <button> (;bn) tag, which is used by some frameworks
HTML.zip 0.42.5 2020-02-03 7.2 Christian J. Robinson - A few more HTML 5 tag mappings
- Housekeeping and bug fixes
HTML.zip 0.42.4 2020-02-02 7.2 Christian J. Robinson - Added super- and sub-script character entities
- Documented tags that are not HTML 5 compatible
- Internal housekeeping
HTML.zip 0.42.2 2020-01-31 7.2 Christian J. Robinson - More HTML 5 tag mappings
- Various tweaks and fixes
HTML.zip 0.42.1 2020-01-30 7.2 Christian J. Robinson - Default browser mapping for Unix wasn't working
HTML.zip 0.42.0 2020-01-28 7.2 Christian J. Robinson - Add support for specific browsers under Windows
- Several tweaks and fixes
HTML.zip 0.41.2 2020-01-27 7.2 Christian J. Robinson - Drop support for obsolete browsers
- More HTML 5 mappings
HTML.zip 0.41.1 2020-01-26 7.2 Christian J. Robinson - Add a few HTML 5 mappings -- more on request
- Make certain tags and the default template valid HTML for modern browsers (using CSS)
HTML.zip 0.40.2 2020-01-26 7.2 Christian J. Robinson - Add left/right single and double quote character entities
- Add mapping for HTML 5 doctype
HTML.zip 0.40.1 2012-11-26 7.2 Christian J. Robinson - More fraction entities added
- globpath() → findfile() for compatibility with Vundle (Leif Arne Storset)
HTML.zip 0.39.4 2011-10-01 7.2 Christian J. Robinson - Added:
  + <param> (;pm) mapping
  + • (&*) mapping
- Fixed:
  + Slight problem with the <noscript> (;ns) mapping
  + HTMLnextInsertPoint() (tab mapping) might not properly jump to the end of a closing comment dilimeter. (Samuel Ferencik)
HTML.zip 0.39.1 2011-08-04 7.2 Christian J. Robinson - Character entity conversion mappings can now encode to &#x..; hexadecimal strings, and decode them as well (Samuel Ferencik)
- Roman numeral character entity mappings added (Samuel Ferencik)
HTML.zip 0.38.1 2011-06-02 7.2 Christian J. Robinson - Euro entity mapping and menu (Samuel Ferencik)
- HTMLnextInsertPoint() sometimes didn't restore options (Samuel Ferencik)
- Entire scriptencoding has been changed to utf8 instead of partially latin1
HTML.zip 0.37.1 2011-04-21 7.2 Christian J. Robinson - Determining the Firefox remote command wasn't working properly (Fr. Robert Bower)
- Fr. Robert Bower added support for Google Chrome on Unix/Linux

(This script _might_ run okay on Vim 7.0/7.1, but it has not been tested -- 7.3 is preferred.)
HTML.zip 0.36.4 2010-08-07 7.0 Christian J. Robinson - More character entity mappings
- Minor changes
HTML.zip 0.36.3 2010-07-01 7.0 Christian J. Robinson - Various minor fixes
HTML.zip 0.36.1 2009-10-28 7.0 Christian J. Robinson - b:no_html_maps can be set like g:no_html_maps
- Israel Chauca Fuentes provided MacOS browser control code
- minor fixes and changes
HTML.zip 0.35.1 2008-06-15 7.0 Christian J. Robinson - Try to safely escape shell commands
HTML.zip 0.35 2008-06-10 7.0 Christian J. Robinson - Added:
  + The colors in the color menu can be displayed in a split window under the GUI, and colors can be selected from the display (;# mapping and :ColorSelect command)
  + g:no_html_map_override can be set to prevent the plugin from overriding already existing mappings, and now warning messages are printed when overriding takes place
  + g:no_html_maps can be set to a regular expression to tell the plugin not to define matching mappings
  + g:html_map_entity_leader can be used to define the character entity mapping leader--works like g:html_map_leader
  + MangleImageTag.vim (used by the ;mi mapping) no longer moves the cursor
  + Miscellaneous minor additions
- Miscellaneous fixes
- Significant refactoring to make maintaining the plugin easier
HTML.zip 0.34 2008-05-07 7.0 Christian J. Robinson - Removed code that was supporting Vim 6, thus:
  + MangleImageTag() used by ;mi mapping should now always compute correct size
  + Various code was simplified
HTML.zip 0.33.1 2008-04-29 6.0 Christian J. Robinson - Character entities for arrows and the Greek alphabet added
- This is the last version that will support Vim 6
HTML.zip 0.32.2 2008-04-13 6.0 Christian J. Robinson - Fixed:
  + Some of the "boolean" configuration variables weren't being tested right (Keith Lancaster)
  + Could get an error when (re-)initializing the menus
- Changed:
  + The ;& and ;% normal mode mappings now behave as operator (motion) mappings--use ;&l or ;%l to emulate the old behavior
- Added:
  + :HTMLmappings reload/html/xhtml can force reloading of the entire script, or switch the mappings into html/xhtml mode
- misc. minor fixes
HTML.zip 0.30 2008-03-07 6.0 Christian J. Robinson - Fixed:
  + Exclude leading indent from the start tag for visual mappings when in visual-line mode
- Added:
  + ;tH (<THEAD>), ;tf (<TFOOT>), and ;tb (<TBODY>) mappings added
HTML.zip 0.29.2 2007-09-10 6.0 Christian J. Robinson - Fixed:
  + Tab mapping wasn't positioning the cursor right when there were multiple spaces between a opening and closing tag
- Added:
  + Make the <html> tag include an xmlns attribute for XHTML
HTML.zip 0.29 2007-08-02 6.0 Christian J. Robinson - Added:
  + g:html_tag_case_autodetect configuration variable
- Fixed:
  + The HTMLnextInsertPoint() function was causing a press enter prompt
  + 'formatoptions' could make visual mappings behave wrong
- Other minor additions and fixes
HTML.zip 0.28.2 2007-06-29 6.0 Christian J. Robinson - Fixed:
  + Defining the menus failed entirely if g:no_html_toolbar was set
- Changes:
  + Add "Select Tag" and "Select Inner Tag" to the PopUp menu
  + Minor tweaks
HTML.zip 0.28 2007-06-24 6.0 Christian J. Robinson - Fixed:
  + Visual mode mappings weren't operating properly when 'selection' was set to "exclusive"
- Added:
  + ;db -- default browser mapping for Windows
HTML.zip 0.27.6 2007-06-12 6.0 Christian J. Robinson - Fixed:
  + Menus weren't getting disabled/enabled properly
- Changed:
  + <DT> and <DD> tags now have closing tags and visual mappings
  + ;;-style mapping for whatever g:html_map_leader is set to
  + Internal code changes
HTML.zip 0.27.4 2007-06-06 6.0 Christian J. Robinson - Added:
  + Smart handling of <EM></EM> tags
  + ;% mapping added -- like ;& but convert to %XX hex strings for URIs
- Changed:
  + Moved ;ns / ;nns mappings to ;ne / ;nne, and moved ;nj mappings to ;ns
HTML.zip 0.27.1 2007-05-31 6.0 Christian J. Robinson - Added:
  + g:force_html_menu can be set to force the HTML menus to be defined in the console
  + g:no_html_menu can be set to stop the menu and toolbar items from being defined
  + w3m browser preview under *nix
- Minor changes and fixes
HTML.zip 0.26.8 2007-05-18 6.0 Christian J. Robinson - Fixed:
  + MangleImageTag() used by ;mi mapping was missing some quotes and computing the wrong sizes when 'encoding' was UTF8 or similar
  + Tab on the end of a line in insert mode moved the cursor a character left
  + Temporarily clear the 'comments' option for the ;js mapping so extraneous // comments weren't inserted
- Various minor changes
HTML.zip 0.26.5 2007-04-23 6.0 Christian J. Robinson - Fixed:
  + When 'filetype' was set in a modeline ":HTMLmappings disable" didn't work
  + Mappings defined with HTMLmap()/HTMLmapo() outside the script weren't redefined when :HTMLmappings disable then enable was run
- Added:
  + ;aH, ;aT, ;aN, etc. now work in insert mode -- they get data from the clipboard
  + ;nj mapping for <NOSCRIPT><CR></NOSCRIPT> added
  + visual and normal mode mappings for ;ob
- Various minor changes and fixes
HTML.zip 0.26 2007-04-10 6.0 Christian J. Robinson - Added:
  + ":HTMLmappings disable/enable" command
  + %vimversion% template token
- Fixed:
  + Some recently added mappings weren't in the menu
  + Inserting the HTML template could trigger the "Press ENTER" prompt
HTML.zip 0.25.5 2007-03-30 6.0 Christian J. Robinson - New mappings:
  + ;sj mapping -- like ;js but for sourced JavaScript
  + ;^ mapping to decode &#...; encoded strings
  + ;& in insert mode inserts a literal &
- Minor changes
HTML.zip 0.25.1 2007-03-11 6.0 Christian J. Robinson - Allow b:html_template to be set in addition to g:html_template
- HTMLnextInsertPoint() used by the <tab> mapping now handles comments, and no longer requires an argument
- ;s4 mapping added -- Same as ;4 only strict rather than transitional
- %time%, %time12%, and %time24% template tokens added, and %date% token is now customizable
- b:do_xhtml_mappings was being ignored
HTML.zip 0.24 2007-02-22 6.0 Christian J. Robinson - In rare cases the script tried to re-enable the ToolBar buttons when they didn't exist
- g:no_html_tab_mapping can be defined to 'move' the <tab> mappings to ;<tab>
- misc. fixes and additions
HTML.zip 0.23.2 2006-12-12 6.0 Christian J. Robinson - Bug when testing for g:html_charset
- Fix a couple of the forms mappings
- Documentation updates and fixes
HTML.zip 0.23.1 2006-12-11 6.0 Christian J. Robinson - Dynamic charset support for the template and the ;ct mapping, based on the 'fileencoding', and 'encoding' options (but the conversion table is limited, see ":help html-author-notes")
- <option> tag wasn't properly closed
HTML.zip 0.22.2 2006-12-04 6.0 Christian J. Robinson - browser_launcher.vim: Bug in detecting the remote command
- ;me mapping wasn't properly positioning the cursor
- Minor documentation fixes
HTML.zip 0.22.1 2006-11-14 6.0 Christian J. Robinson - Make the leader of the ;-mappings configurable with g:html_map_leader
- Fix error when g:no_html_toolbar is set
HTML.zip 0.21.2 2006-10-13 6.0 Christian J. Robinson - ;im mapping wasn't properly positioning the cursor
- Minor improvement to the HTMLnextInsertPoint function used by the tab mapping
HTML.zip 0.21 2006-10-04 6.0 Christian J. Robinson - Basic support for XHTML added--see ":help g:do_xhtml_mappings"
- Misc. minor fixes
HTML.zip 0.20.4 2006-05-28 6.0 Christian J. Robinson - ;h1 - ;h6 and mappings no longer create center aligned tags, ;hr no longer has a default width. Use ;H1 - ;H6 / ;Hr if you still want the old default behavior.
- Don't display menu/toolbar entries for browsers that don't exist. (Unix only)
- Allow .-repeating of operator mappings to work properly.
- Code improvements and bug fixes.
HTML.zip 0.19 2006-01-18 6.0 Christian J. Robinson - Smart-handling of certain tags (bold, italic, underline, comments) if syntax highlighting is on.
HTML.zip 0.18 2005-12-26 6.0 Christian J. Robinson - Implemented normal mode mappings that take an operator (motion) for Vim 7.
HTML.zip 0.17.1 2005-10-22 6.0 Christian J. Robinson - Some visual mappings had insert offset problems when 'indentexpr' was set.
- Author email in templates wasn't being encoded (bug since the template became configurable).
HTML.zip 0.16.2 2005-10-08 6.0 Christian J. Robinson Some visual mappings didn't work with the extra code used to prevent a (visual)bell.
HTML.zip 0.16 2005-07-13 6.0 Christian J. Robinson - Fixed some of the forms visual mappings.
- Added code to prevent a (visual)bell with some of the visual mappings when 'showmatch' was enabled.
HTML.zip 0.15.1 2005-05-19 6.0 Christian J. Robinson - MangleImageTag was getting the width and height of gifs reversed.
- Other minor bugs fixed.
HTML.zip 0.15 2004-06-09 6.0 Christian J. Robinson - A bug crept in that prevented the work-around for the GTK2 toolbar pixmap bug from working.
HTML.zip 0.14 2004-04-22 6.0 Christian J. Robinson - ;& mapping to change the visual selection or character under the cursor to its &#...; equivalent.
- ;mi mapping to automatically update the WIDTH/HEIGHT attributes in an IMG tag. (MangleImageTag.vim included. -- Experimental! See ":help ;mi".)
- Misc. bug fixes and tweaks.
HTML.zip 0.13 2004-03-16 6.0 Christian J. Robinson - The template used by ;html is now configurable.
- Colors menu changed from a cascading menu to an alphabetic menu.
- Misc. tweaks.
HTML.zip 0.12 2003-11-04 6.0 Christian J. Robinson - Insert mode mappings weren't buffer-local. (Error when removing Vim5 support.)
HTML.zip 0.11 2003-10-27 6.0 Christian J. Robinson - HTML menu and ToolBar weren't being enabled sometimes when the script was loaded again.
- Abandoned support for vim versions prior to 6.
- More minor changes.
HTML.zip 0.10 2003-09-13 5.7 Christian J. Robinson - Mozilla mappings added.
- HTML encode author email (to prevent spam harvesters).
- Work-around for a bug in the Vim GTK2 toolbar interface that doesn't properly find icons.
- Other minor changes.
ip used for rating:

If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to the maillist. Help Bram help Uganda.