annotate runtime/indent/html.vim @ 3634:286ba0251c0a v7.3.577

updated for version 7.3.577 Problem: Size of memory does not fit in 32 bit unsigned. Solution: Use Kbyte instead of byte. Call GlobalMemoryStatusEx() instead of GlobalMemoryStatus() when available.
author Bram Moolenaar <bram@vim.org>
date Fri, 29 Jun 2012 15:51:30 +0200
parents e63691e7c504
children a5352e73dc00
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1 " Description: html indenter
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2 " Author: Johannes Zellner <johannes@zellner.org>
1121
e63691e7c504 updated for version 7.1a
vimboss
parents: 867
diff changeset
3 " Last Change: Mo, 05 Jun 2006 22:32:41 CEST
867
a5677b7ce858 updated for version 7.0g04
vimboss
parents: 856
diff changeset
4 " Restoring 'cpo' and 'ic' added by Bram 2006 May 5
856
8cd729851562 updated for version 7.0g
vimboss
parents: 826
diff changeset
5 " Globals: g:html_indent_tags -- indenting tags
826
1cdd2661f34c updated for version 7.0d01
vimboss
parents: 7
diff changeset
6 " g:html_indent_strict -- inhibit 'O O' elements
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7 " g:html_indent_strict_table -- inhibit 'O -' elements
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9 " Only load this indent file when no other was loaded.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
10 if exists("b:did_indent")
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
11 finish
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
12 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
13 let b:did_indent = 1
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
14
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
15
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
16 " [-- local settings (must come before aborting the script) --]
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
17 setlocal indentexpr=HtmlIndentGet(v:lnum)
826
1cdd2661f34c updated for version 7.0d01
vimboss
parents: 7
diff changeset
18 setlocal indentkeys=o,O,*<Return>,<>>,{,}
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
19
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
20
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
21 if exists('g:html_indent_tags')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
22 unlet g:html_indent_tags
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
23 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
24
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
25 " [-- helper function to assemble tag list --]
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
26 fun! <SID>HtmlIndentPush(tag)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
27 if exists('g:html_indent_tags')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
28 let g:html_indent_tags = g:html_indent_tags.'\|'.a:tag
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
29 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
30 let g:html_indent_tags = a:tag
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
31 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
32 endfun
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
33
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
34
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
35 " [-- <ELEMENT ? - - ...> --]
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
36 call <SID>HtmlIndentPush('a')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
37 call <SID>HtmlIndentPush('abbr')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
38 call <SID>HtmlIndentPush('acronym')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
39 call <SID>HtmlIndentPush('address')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
40 call <SID>HtmlIndentPush('b')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
41 call <SID>HtmlIndentPush('bdo')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
42 call <SID>HtmlIndentPush('big')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
43 call <SID>HtmlIndentPush('blockquote')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
44 call <SID>HtmlIndentPush('button')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
45 call <SID>HtmlIndentPush('caption')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
46 call <SID>HtmlIndentPush('center')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
47 call <SID>HtmlIndentPush('cite')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
48 call <SID>HtmlIndentPush('code')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
49 call <SID>HtmlIndentPush('colgroup')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
50 call <SID>HtmlIndentPush('del')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
51 call <SID>HtmlIndentPush('dfn')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
52 call <SID>HtmlIndentPush('dir')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
53 call <SID>HtmlIndentPush('div')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
54 call <SID>HtmlIndentPush('dl')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
55 call <SID>HtmlIndentPush('em')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
56 call <SID>HtmlIndentPush('fieldset')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
57 call <SID>HtmlIndentPush('font')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
58 call <SID>HtmlIndentPush('form')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
59 call <SID>HtmlIndentPush('frameset')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
60 call <SID>HtmlIndentPush('h1')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
61 call <SID>HtmlIndentPush('h2')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
62 call <SID>HtmlIndentPush('h3')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
63 call <SID>HtmlIndentPush('h4')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
64 call <SID>HtmlIndentPush('h5')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
65 call <SID>HtmlIndentPush('h6')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
66 call <SID>HtmlIndentPush('i')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
67 call <SID>HtmlIndentPush('iframe')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
68 call <SID>HtmlIndentPush('ins')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
69 call <SID>HtmlIndentPush('kbd')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
70 call <SID>HtmlIndentPush('label')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
71 call <SID>HtmlIndentPush('legend')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
72 call <SID>HtmlIndentPush('map')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
73 call <SID>HtmlIndentPush('menu')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
74 call <SID>HtmlIndentPush('noframes')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
75 call <SID>HtmlIndentPush('noscript')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
76 call <SID>HtmlIndentPush('object')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
77 call <SID>HtmlIndentPush('ol')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
78 call <SID>HtmlIndentPush('optgroup')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
79 " call <SID>HtmlIndentPush('pre')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
80 call <SID>HtmlIndentPush('q')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
81 call <SID>HtmlIndentPush('s')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
82 call <SID>HtmlIndentPush('samp')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
83 call <SID>HtmlIndentPush('script')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
84 call <SID>HtmlIndentPush('select')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
85 call <SID>HtmlIndentPush('small')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
86 call <SID>HtmlIndentPush('span')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
87 call <SID>HtmlIndentPush('strong')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
88 call <SID>HtmlIndentPush('style')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
89 call <SID>HtmlIndentPush('sub')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
90 call <SID>HtmlIndentPush('sup')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
91 call <SID>HtmlIndentPush('table')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
92 call <SID>HtmlIndentPush('textarea')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
93 call <SID>HtmlIndentPush('title')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
94 call <SID>HtmlIndentPush('tt')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
95 call <SID>HtmlIndentPush('u')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
96 call <SID>HtmlIndentPush('ul')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
97 call <SID>HtmlIndentPush('var')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
98
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
99
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
100 " [-- <ELEMENT ? O O ...> --]
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
101 if !exists('g:html_indent_strict')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
102 call <SID>HtmlIndentPush('body')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
103 call <SID>HtmlIndentPush('head')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
104 call <SID>HtmlIndentPush('html')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
105 call <SID>HtmlIndentPush('tbody')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
106 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
107
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
108
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
109 " [-- <ELEMENT ? O - ...> --]
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
110 if !exists('g:html_indent_strict_table')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
111 call <SID>HtmlIndentPush('th')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
112 call <SID>HtmlIndentPush('td')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
113 call <SID>HtmlIndentPush('tr')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
114 call <SID>HtmlIndentPush('tfoot')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
115 call <SID>HtmlIndentPush('thead')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
116 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
117
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
118 delfun <SID>HtmlIndentPush
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
119
867
a5677b7ce858 updated for version 7.0g04
vimboss
parents: 856
diff changeset
120 let s:cpo_save = &cpo
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
121 set cpo-=C
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
122
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
123 " [-- count indent-increasing tags of line a:lnum --]
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
124 fun! <SID>HtmlIndentOpen(lnum, pattern)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
125 let s = substitute('x'.getline(a:lnum),
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
126 \ '.\{-}\(\(<\)\('.a:pattern.'\)\>\)', "\1", 'g')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
127 let s = substitute(s, "[^\1].*$", '', '')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
128 return strlen(s)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
129 endfun
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
130
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
131 " [-- count indent-decreasing tags of line a:lnum --]
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
132 fun! <SID>HtmlIndentClose(lnum, pattern)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
133 let s = substitute('x'.getline(a:lnum),
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
134 \ '.\{-}\(\(<\)/\('.a:pattern.'\)\>>\)', "\1", 'g')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
135 let s = substitute(s, "[^\1].*$", '', '')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
136 return strlen(s)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
137 endfun
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
138
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
139 " [-- count indent-increasing '{' of (java|css) line a:lnum --]
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
140 fun! <SID>HtmlIndentOpenAlt(lnum)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
141 return strlen(substitute(getline(a:lnum), '[^{]\+', '', 'g'))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
142 endfun
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
143
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
144 " [-- count indent-decreasing '}' of (java|css) line a:lnum --]
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
145 fun! <SID>HtmlIndentCloseAlt(lnum)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
146 return strlen(substitute(getline(a:lnum), '[^}]\+', '', 'g'))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
147 endfun
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
148
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
149 " [-- return the sum of indents respecting the syntax of a:lnum --]
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
150 fun! <SID>HtmlIndentSum(lnum, style)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
151 if a:style == match(getline(a:lnum), '^\s*</')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
152 if a:style == match(getline(a:lnum), '^\s*</\<\('.g:html_indent_tags.'\)\>')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
153 let open = <SID>HtmlIndentOpen(a:lnum, g:html_indent_tags)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
154 let close = <SID>HtmlIndentClose(a:lnum, g:html_indent_tags)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
155 if 0 != open || 0 != close
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
156 return open - close
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
157 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
158 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
159 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
160 if '' != &syntax &&
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
161 \ synIDattr(synID(a:lnum, 1, 1), 'name') =~ '\(css\|java\).*' &&
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
162 \ synIDattr(synID(a:lnum, strlen(getline(a:lnum)), 1), 'name')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
163 \ =~ '\(css\|java\).*'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
164 if a:style == match(getline(a:lnum), '^\s*}')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
165 return <SID>HtmlIndentOpenAlt(a:lnum) - <SID>HtmlIndentCloseAlt(a:lnum)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
166 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
167 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
168 return 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
169 endfun
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
170
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
171 fun! HtmlIndentGet(lnum)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
172 " Find a non-empty line above the current line.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
173 let lnum = prevnonblank(a:lnum - 1)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
174
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
175 " Hit the start of the file, use zero indent.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
176 if lnum == 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
177 return 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
178 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
179
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
180 let restore_ic = &ic
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
181 setlocal ic " ignore case
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
182
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
183 " [-- special handling for <pre>: no indenting --]
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
184 if getline(a:lnum) =~ '\c</pre>'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
185 \ || 0 < searchpair('\c<pre>', '', '\c</pre>', 'nWb')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
186 \ || 0 < searchpair('\c<pre>', '', '\c</pre>', 'nW')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
187 " we're in a line with </pre> or inside <pre> ... </pre>
867
a5677b7ce858 updated for version 7.0g04
vimboss
parents: 856
diff changeset
188 if restore_ic == 0
a5677b7ce858 updated for version 7.0g04
vimboss
parents: 856
diff changeset
189 setlocal noic
a5677b7ce858 updated for version 7.0g04
vimboss
parents: 856
diff changeset
190 endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
191 return -1
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
192 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
193
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
194 " [-- special handling for <javascript>: use cindent --]
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
195 let js = '<script.*type\s*=\s*.*java'
1121
e63691e7c504 updated for version 7.1a
vimboss
parents: 867
diff changeset
196
e63691e7c504 updated for version 7.1a
vimboss
parents: 867
diff changeset
197 """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
e63691e7c504 updated for version 7.1a
vimboss
parents: 867
diff changeset
198 " by Tye Zdrojewski <zdro@yahoo.com>, 05 Jun 2006
e63691e7c504 updated for version 7.1a
vimboss
parents: 867
diff changeset
199 " ZDR: This needs to be an AND (we are 'after the start of the pair' AND
e63691e7c504 updated for version 7.1a
vimboss
parents: 867
diff changeset
200 " we are 'before the end of the pair'). Otherwise, indentation
e63691e7c504 updated for version 7.1a
vimboss
parents: 867
diff changeset
201 " before the start of the script block will be affected; the end of
e63691e7c504 updated for version 7.1a
vimboss
parents: 867
diff changeset
202 " the pair will still match if we are before the beginning of the
e63691e7c504 updated for version 7.1a
vimboss
parents: 867
diff changeset
203 " pair.
e63691e7c504 updated for version 7.1a
vimboss
parents: 867
diff changeset
204 "
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
205 if 0 < searchpair(js, '', '</script>', 'nWb')
1121
e63691e7c504 updated for version 7.1a
vimboss
parents: 867
diff changeset
206 \ && 0 < searchpair(js, '', '</script>', 'nW')
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
207 " we're inside javascript
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
208 if getline(lnum) !~ js && getline(a:lnum) != '</script>'
867
a5677b7ce858 updated for version 7.0g04
vimboss
parents: 856
diff changeset
209 if restore_ic == 0
a5677b7ce858 updated for version 7.0g04
vimboss
parents: 856
diff changeset
210 setlocal noic
a5677b7ce858 updated for version 7.0g04
vimboss
parents: 856
diff changeset
211 endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
212 return cindent(a:lnum)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
213 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
214 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
215
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
216 if getline(lnum) =~ '\c</pre>'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
217 " line before the current line a:lnum contains
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
218 " a closing </pre>. --> search for line before
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
219 " starting <pre> to restore the indent.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
220 let preline = prevnonblank(search('\c<pre>', 'bW') - 1)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
221 if preline > 0
867
a5677b7ce858 updated for version 7.0g04
vimboss
parents: 856
diff changeset
222 if restore_ic == 0
a5677b7ce858 updated for version 7.0g04
vimboss
parents: 856
diff changeset
223 setlocal noic
a5677b7ce858 updated for version 7.0g04
vimboss
parents: 856
diff changeset
224 endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
225 return indent(preline)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
226 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
227 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
228
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
229 let ind = <SID>HtmlIndentSum(lnum, -1)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
230 let ind = ind + <SID>HtmlIndentSum(a:lnum, 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
231
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
232 if restore_ic == 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
233 setlocal noic
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
234 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
235
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
236 return indent(lnum) + (&sw * ind)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
237 endfun
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
238
867
a5677b7ce858 updated for version 7.0g04
vimboss
parents: 856
diff changeset
239 let &cpo = s:cpo_save
a5677b7ce858 updated for version 7.0g04
vimboss
parents: 856
diff changeset
240 unlet s:cpo_save
a5677b7ce858 updated for version 7.0g04
vimboss
parents: 856
diff changeset
241
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
242 " [-- EOF <runtime>/indent/html.vim --]