sponsor Vim development Vim logo Vim Book Ad

htmlcmd.vim : Rich HTML/XML commands

 script karma  Rating 34/16, Downloaded by 5383  Comments, bugs, improvements  Vim wiki

created by
Michael Geddes
 
script type
utility
 
description
This script handles a number of mundane tasks in HTML / XML.  It allows you to create a default HTML header (Alt+0),  to define headings <h1> .. <h6> (Alt+1.. Alt+6), to toggle bold, italic, underline, paragraphs & kbd commands.  It gives shortcuts for ordered/unordered lists and row definitions.  

The script has commands to insert horizontal rules, line-breaks, and a number of  special symbols (just email me to add your favourite).  

It has imap mappings that give you ampersands (&&), smart-quotes (single - &' and double &"), <, > symbols,   and more.  It allow you to insert these and text descriptors or as numbers (for strict XML)

You can close the next open tag (alt-;) or close all open tags at that point (alt->).  
Not you may need to remap these for other platforms.


If you have defined 'htmlcmd_AUTOCLOSE' then there is some reasonably intrusive code that will close open tags:
try typing this
<p>Testing<b>bold</p>

This should automatically close the <b>

You can also generate a quick Table Of Contents for your document based on <H1>..<H6> headings.  There is a menu item to insert it.. and any options you give
are remembered for when you re-generate the TOC.

GenerateTOC( [<headingtypes>| * ])
:GenTOC [<headingtypes>| * ]

The optional argument is a string of types for each indent level. Eg. " 1ai." would mean level 1 is default (bullet), level 2 is a numbered list, level 3 has letters and level three has roman numerals.
It uses references where it can find them, and generates new ones where it can't.
The arguments supplied are remembered so the TOC can be regenerated without resuplying them.
If * is supplied as an argument, the script prompts for arguments - showing what the current values are.

When used with buffermenu.vim - Menus (for TOC generation) are local to the buffer.
 
install details
Use as a filetype plugin  (tip - make a directory ftplugin/html and place it in there)
The menu can also work with buffermenu.vim.

By using buffoptions, this should work with version 5.7 and greater as the 6.0 specific plugin-style codes are stripped in the latest version of buffoptions.

 

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
htmlcmd.vim 2.5 2002-08-26 6.0 Michael Geddes Added more menus - made them useful for detaching, and able to
customise the name.
htmlcmd.vim 2.4 2002-04-03 6.0 Michael Geddes Command  :GenTOC added  (calls GenerateTOC)
This now remembers the arguments supplied so the TOC can be regenerated without resuplying them.
Also supports  * as an argument - providing a Prompt for arguments - showing what the current values are.
htmlcmd.vim 2.3 2002-03-19 5.7 Michael Geddes Fixed some maps that didn't have <buffer> specifed.  Added <localleader> to replace ',' as prefix.  Updated the doco.
Changed the insert-map of '>' to be NOT mapped - define htmlcmd_AUTOCLOSE to map it.
I would like some feedback on the response speed for large documents - any noteable examples would be good.
Also  -- any users who need to make modifications due to their setup, I would be interested in hearing from.
Email supplied in script.
htmlcmd.vim 2.2 2001-10-14 6.0 Michael Geddes Have redone the auto-closing maps to make them a lot quicker.
Added <m-;> to close a single tag and <m-s-;> to close all tags.
Added a menu for Table Of Contents
htmlcmd.vim 2.1 2001-08-01 6.0 Michael Geddes Fixed bug that stopped this working as an ftplugin
ip used for rating: 3.141.199.243

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.
   
Vim at Github