indent/html.vim : alternative html indent script
script karma |
Rating 93/47,
Downloaded by 13434 |
Comments, bugs, improvements
|
Vim wiki
|
created by |
Andy Wokula |
|
script type |
indent |
|
description |
This script is based on the distributed indent scripts for HTML (and CSS). The original script becomes very slow when indenting more than a few lines, thus here is an improvement.
Customization: Variables you can set in the vimrc. Given values are examples to change the defaults.
Note: This applies to v0.6 (!). Earlier version used :IndHtmlLocal for customization. Details can always be found in the script header.
You can set the indent for the first line after <script> and <style> "block tags" (default "zero"):
:let g:html_indent_script1 = "inc"
:let g:html_indent_style1 = "inc"
VALUE MEANING
"zero" zero indent
"auto" auto indent (same indent as the blocktag)
"inc" auto indent + one indent step
The following <tags> increase the indent (for what follows) per default (taken from the original script, but slightly modified):
a, abbr, acronym, address, b, bdo, big, blockquote, button, caption, center, cite, code, colgroup, del, dfn, dir, div, dl, em, fieldset, font, form, frameset, h1, h2, h3, h4, h5, h6, i, iframe, ins, kbd, label, legend, map, menu, noframes, noscript, object, ol, optgroup, q, s, samp, select, small, span, strong, sub, sup, table, textarea, title, tt, u, ul, var, th, td, tr, tfoot, thead
(added with v0.8): area, article, aside, audio, bdi, canvas, command, datalist, details, embed, figure, footer, header, group, keygen, mark, math, meter, nav, output, progress, ruby, section, svg, texture, time, video, wbr, text
You can add further tags with
:let g:html_indent_inctags = "html,body,head,tbody"
" the original script uses the g:html_indent_strict variable to include these tags
You can remove tags with
:let g:html_indent_autotags = "th,td,tr,tfoot,thead"
" the original script uses the g:html_indent_strict_table variable to include these tags
Default value is empty for both variables. The default tags that increase indent are defined once per session only.
Problems and Bugs:
- still no indent rules for attributes spanning several lines
- sometimes cindent() thinks it is better to use zero indent for what follows ...
- some tags increase indent per default, but their closing tag is optional, e.g. <td> -- the script cannot detect missing closing tags
Suggestions, bug reports welcome (I'm not writing HTML regularly).
2014 Jul 04: Vim 7.4.356 or later includes a descendant of this script (the official script is now maintained by Bram and includes massive changes)
2013 Jun 13: Vim 7.3.1180 or later includes the latest version of this script. |
|
install details |
Unix: copy script to ~/.vim/indent
Win: copy script to ~\vimfiles\indent
Enable filetype detection and use of indent plugins:
:filetype indent on |
|
script versions (upload new version)
Click on the package to download.
html.vim |
0.10 |
2014-01-27 |
7.0 |
Andy Wokula |
added b:html_indent_usestate; and a bug fix |
html.vim |
0.8 |
2011-09-11 |
7.0 |
Andy Wokula |
added HTML5 tags (thx to J. Zuckerman) |
html.vim |
0.6 |
2008-04-28 |
7.0 |
Andy Wokula |
customization revised, no other changes |
html.vim |
0.5 |
2008-03-09 |
7.0 |
Andy Wokula |
Fixed: 'indk' when breaking a line with Enter (e.g. given the line "<div><center></center>", inserting Enter after "<center>" now adds an indent for the new line)
Change: line must start with a closing tag (old: any tag) to get same indent as the starting tag |
html.vim |
0.4 |
2007-11-21 |
7.0 |
Andy Wokula |
Added: configurable indent for the first line after <script> or <style> |
html.vim |
0.3.2 |
2007-11-21 |
7.0 |
Andy Wokula |
Another dumb bug fixed: didn't match tag names with digits (h1-h6)
goody: simple arg-completion for IndHtmlLocal |
html.vim |
0.3.1 |
2007-11-20 |
7.0 |
Andy Wokula |
Bugfix: didn't detect "-->" as end of region |
html.vim |
0.3 |
2007-11-19 |
7.0 |
Andy Wokula |
now indents <style> regions |
html.vim |
0.2 |
2007-11-18 |
7.0 |
Andy Wokula |
Initial upload |
ip used for rating: 142.132.191.50
|