comparison runtime/indent/tex.vim @ 3237:91e53bcb7946

Updated runtime files.
author Bram Moolenaar <bram@vim.org>
date Fri, 30 Dec 2011 13:11:27 +0100
parents 8b8ef1fed009
children 2cfb68fa26cd
comparison
equal deleted inserted replaced
3236:12a5ea0526b1 3237:91e53bcb7946
1 " Vim indent file 1 " Vim indent file
2 " Language: LaTeX 2 " Language: LaTeX
3 " Maintainer: Zhou YiChao <broken.zhou@gmail.com> 3 " Maintainer: Zhou YiChao <broken.zhou@gmail.com>
4 " Created: Sat, 16 Feb 2002 16:50:19 +0100 4 " Created: Sat, 16 Feb 2002 16:50:19 +0100
5 " Last Change: Tue, 25 Sep 2011 5 " Last Change: 2011 Dec 24
6 " Last Update: 25th Sep 2002, by LH : 6 " Last Update: 25th Sep 2002, by LH :
7 " (*) better support for the option 7 " (*) better support for the option
8 " (*) use some regex instead of several '||'. 8 " (*) use some regex instead of several '||'.
9 " Oct 9th, 2003, by JT: 9 " Oct 9th, 2003, by JT:
10 " (*) don't change indentation of lines starting with '%' 10 " (*) don't change indentation of lines starting with '%'
35 " 35 "
36 " * g:tex_indent_brace 36 " * g:tex_indent_brace
37 " 37 "
38 " If this variable is unset or non-zero, it will use smartindent-like style 38 " If this variable is unset or non-zero, it will use smartindent-like style
39 " for "{}" and "[]" 39 " for "{}" and "[]"
40 " 40 "
41 " * g:tex_indent_items 41 " * g:tex_indent_items
42 " 42 "
43 " If this variable is set, item-environments are indented like Emacs does 43 " If this variable is set, item-environments are indented like Emacs does
44 " it, i.e., continuation lines are indented with a shiftwidth. 44 " it, i.e., continuation lines are indented with a shiftwidth.
45 " 45 "
46 " NOTE: I've already set the variable below; delete the corresponding line 46 " NOTE: I've already set the variable below; delete the corresponding line
47 " if you don't like this behaviour. 47 " if you don't like this behaviour.
48 " 48 "
49 " Per default, it is unset. 49 " Per default, it is unset.
50 " 50 "
51 " set unset 51 " set unset
52 " ---------------------------------------------------------------- 52 " ----------------------------------------------------------------
53 " \begin{itemize} \begin{itemize} 53 " \begin{itemize} \begin{itemize}
54 " \item blablabla \item blablabla 54 " \item blablabla \item blablabla
55 " bla bla bla bla bla bla 55 " bla bla bla bla bla bla
56 " \item blablabla \item blablabla 56 " \item blablabla \item blablabla
57 " bla bla bla bla bla bla 57 " bla bla bla bla bla bla
58 " \end{itemize} \end{itemize} 58 " \end{itemize} \end{itemize}
59 " 59 "
60 " 60 "
61 " * g:tex_items 61 " * g:tex_items
62 " 62 "
63 " A list of tokens to be considered as commands for the beginning of an item 63 " A list of tokens to be considered as commands for the beginning of an item
64 " command. The tokens should be separated with '\|'. The initial '\' should 64 " command. The tokens should be separated with '\|'. The initial '\' should
65 " be escaped. The default is '\\bibitem\|\\item'. 65 " be escaped. The default is '\\bibitem\|\\item'.
66 " 66 "
67 " * g:tex_itemize_env 67 " * g:tex_itemize_env
68 " 68 "
69 " A list of environment names, separated with '\|', where the items (item 69 " A list of environment names, separated with '\|', where the items (item
70 " commands matching g:tex_items) may appear. The default is 70 " commands matching g:tex_items) may appear. The default is
71 " 'itemize\|description\|enumerate\|thebibliography'. 71 " 'itemize\|description\|enumerate\|thebibliography'.
72 " 72 "
73 " * g:tex_noindent_env 73 " * g:tex_noindent_env
74 " 74 "
75 " A list of environment names. separated with '\|', where no indentation is 75 " A list of environment names. separated with '\|', where no indentation is
76 " required. The default is 'document\|verbatim'. 76 " required. The default is 'document\|verbatim'.
77 " 77 "
78 " * g:tex_indent_and 78 " * g:tex_indent_and
79 " 79 "
80 " If this variable is unset or zero, vim will try to align the line with first 80 " If this variable is unset or zero, vim will try to align the line with first
81 " "&". This is pretty useful when you use environment like table or align. 81 " "&". This is pretty useful when you use environment like table or align.
82 " Note that this feature need to search back some line, so vim may become 82 " Note that this feature need to search back some line, so vim may become
83 " a little slow. 83 " a little slow.
84 " 84 "
85 " }}} 85 " }}}
86 86
87 if exists("b:did_indent") 87 if exists("b:did_indent")
88 finish 88 finish
89 endif 89 endif
90 let b:did_indent = 1 90 let b:did_indent = 1
102 if g:tex_indent_items 102 if g:tex_indent_items
103 if !exists("g:tex_itemize_env") 103 if !exists("g:tex_itemize_env")
104 let g:tex_itemize_env = 'itemize\|description\|enumerate\|thebibliography' 104 let g:tex_itemize_env = 'itemize\|description\|enumerate\|thebibliography'
105 endif 105 endif
106 if !exists('g:tex_items') 106 if !exists('g:tex_items')
107 let g:tex_items = '\\bibitem\|\\item' 107 let g:tex_items = '\\bibitem\|\\item'
108 endif 108 endif
109 else 109 else
110 let g:tex_items = '' 110 let g:tex_items = ''
111 endif 111 endif
112 112
123 123
124 " Only define the function once 124 " Only define the function once
125 if exists("*GetTeXIndent") | finish 125 if exists("*GetTeXIndent") | finish
126 endif 126 endif
127 127
128 let s:cpo_save = &cpo
129 set cpo&vim
128 130
129 function GetTeXIndent() 131 function GetTeXIndent()
130 " Find a non-blank line above the current line. 132 " Find a non-blank line above the current line.
131 let lnum = prevnonblank(v:lnum - 1) 133 let lnum = prevnonblank(v:lnum - 1)
132 134
135 let lnum = prevnonblank(lnum - 1) 137 let lnum = prevnonblank(lnum - 1)
136 endwhile 138 endwhile
137 139
138 " At the start of the file use zero indent. 140 " At the start of the file use zero indent.
139 if lnum == 0 141 if lnum == 0
140 return 0 142 return 0
141 endif 143 endif
142 144
143 let line = getline(lnum) " last line 145 let line = getline(lnum) " last line
144 let cline = getline(v:lnum) " current line 146 let cline = getline(v:lnum) " current line
145 147
157 endwhile 159 endwhile
158 endif 160 endif
159 161
160 162
161 if lnum == 0 163 if lnum == 0
162 return 0 164 return 0
163 endif 165 endif
164 166
165 let ind = indent(lnum) 167 let ind = indent(lnum)
166 168
167 " New code for comment: retain the indent of current line 169 " New code for comment: retain the indent of current line
169 return indent(v:lnum) 171 return indent(v:lnum)
170 endif 172 endif
171 173
172 " Add a 'shiftwidth' after beginning of environments. 174 " Add a 'shiftwidth' after beginning of environments.
173 " Don't add it for \begin{document} and \begin{verbatim} 175 " Don't add it for \begin{document} and \begin{verbatim}
174 ""if line =~ '^\s*\\begin{\(.*\)}' && line !~ 'verbatim' 176 ""if line =~ '^\s*\\begin{\(.*\)}' && line !~ 'verbatim'
175 " LH modification : \begin does not always start a line 177 " LH modification : \begin does not always start a line
176 " ZYC modification : \end after \begin won't cause wrong indent anymore 178 " ZYC modification : \end after \begin won't cause wrong indent anymore
177 if line =~ '\\begin{.*}' && line !~ g:tex_noindent_env 179 if line =~ '\\begin{.*}' && line !~ g:tex_noindent_env
178 \ && line !~ '\\begin{.\{-}}.*\\end{.*}' 180 \ && line !~ '\\begin{.\{-}}.*\\end{.*}'
179 181
245 endif 247 endif
246 248
247 return ind 249 return ind
248 endfunction 250 endfunction
249 251
252 let &cpo = s:cpo_save
253 unlet s:cpo_save
254
250 " vim: set sw=4 textwidth=80: 255 " vim: set sw=4 textwidth=80: