Mercurial > vim
annotate runtime/doc/indent.txt @ 17061:051a2f640a6e v8.1.1530
patch 8.1.1530: Travis config is not optimal
commit https://github.com/vim/vim/commit/f42397c395ec8ff2dffef914805b4d9cbf1d600b
Author: Bram Moolenaar <Bram@vim.org>
Date: Fri Jun 14 20:47:49 2019 +0200
patch 8.1.1530: Travis config is not optimal
Problem: Travis config is not optimal.
Solution: Remove system conditions. Do not use excluding matrix. Cache OSX
results. (Ozaki Kiichi, closes #4521)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Fri, 14 Jun 2019 21:00:08 +0200 |
parents | c3c1abe7aff2 |
children | 2704c4e3e20a |
rev | line source |
---|---|
15932 | 1 *indent.txt* For Vim version 8.1. Last change: 2019 Feb 21 |
7 | 2 |
3 | |
4 VIM REFERENCE MANUAL by Bram Moolenaar | |
5 | |
6 | |
7 This file is about indenting C programs and other files. | |
8 | |
1620 | 9 1. Indenting C style programs |C-indenting| |
7 | 10 2. Indenting by expression |indent-expression| |
11 | |
12 ============================================================================== | |
1620 | 13 1. Indenting C style programs *C-indenting* |
7 | 14 |
1620 | 15 The basics for C style indenting are explained in section |30.2| of the user |
16 manual. | |
7 | 17 |
1620 | 18 Vim has options for automatically indenting C style program files. Many |
19 programming languages including Java and C++ follow very closely the | |
20 formatting conventions established with C. These options affect only the | |
21 indent and do not perform other formatting. There are additional options that | |
22 affect other kinds of formatting as well as indenting, see |format-comments|, | |
23 |fo-table|, |gq| and |formatting| for the main ones. | |
7 | 24 |
25 Note that this will not work when the |+smartindent| or |+cindent| features | |
26 have been disabled at compile time. | |
27 | |
1620 | 28 There are in fact four main methods available for indentation, each one |
29 overrides the previous if it is enabled, or non-empty for 'indentexpr': | |
7 | 30 'autoindent' uses the indent from the previous line. |
31 'smartindent' is like 'autoindent' but also recognizes some C syntax to | |
32 increase/reduce the indent where appropriate. | |
33 'cindent' Works more cleverly than the other two and is configurable to | |
34 different indenting styles. | |
35 'indentexpr' The most flexible of all: Evaluates an expression to compute | |
36 the indent of a line. When non-empty this method overrides | |
37 the other ones. See |indent-expression|. | |
38 The rest of this section describes the 'cindent' option. | |
39 | |
40 Note that 'cindent' indenting does not work for every code scenario. Vim | |
829 | 41 is not a C compiler: it does not recognize all syntax. One requirement is |
42 that toplevel functions have a '{' in the first column. Otherwise they are | |
43 easily confused with declarations. | |
7 | 44 |
45 These four options control C program indenting: | |
46 'cindent' Enables Vim to perform C program indenting automatically. | |
47 'cinkeys' Specifies which keys trigger reindenting in insert mode. | |
48 'cinoptions' Sets your preferred indent style. | |
49 'cinwords' Defines keywords that start an extra indent in the next line. | |
50 | |
51 If 'lisp' is not on and 'equalprg' is empty, the "=" operator indents using | |
52 Vim's built-in algorithm rather than calling an external program. | |
53 | |
54 See |autocommand| for how to set the 'cindent' option automatically for C code | |
55 files and reset it for others. | |
56 | |
57 *cinkeys-format* *indentkeys-format* | |
58 The 'cinkeys' option is a string that controls Vim's indenting in response to | |
59 typing certain characters or commands in certain contexts. Note that this not | |
60 only triggers C-indenting. When 'indentexpr' is not empty 'indentkeys' is | |
61 used instead. The format of 'cinkeys' and 'indentkeys' is equal. | |
62 | |
15701
9cd11f6beb70
patch 8.1.0858: 'indentkeys' and 'cinkeys' defaults are different
Bram Moolenaar <Bram@vim.org>
parents:
15033
diff
changeset
|
63 The default is "0{,0},0),0],:,0#,!^F,o,O,e" which specifies that indenting |
9cd11f6beb70
patch 8.1.0858: 'indentkeys' and 'cinkeys' defaults are different
Bram Moolenaar <Bram@vim.org>
parents:
15033
diff
changeset
|
64 occurs as follows: |
7 | 65 |
66 "0{" if you type '{' as the first character in a line | |
67 "0}" if you type '}' as the first character in a line | |
68 "0)" if you type ')' as the first character in a line | |
15701
9cd11f6beb70
patch 8.1.0858: 'indentkeys' and 'cinkeys' defaults are different
Bram Moolenaar <Bram@vim.org>
parents:
15033
diff
changeset
|
69 "0]" if you type ']' as the first character in a line |
7 | 70 ":" if you type ':' after a label or case statement |
71 "0#" if you type '#' as the first character in a line | |
72 "!^F" if you type CTRL-F (which is not inserted) | |
73 "o" if you type a <CR> anywhere or use the "o" command (not in | |
74 insert mode!) | |
75 "O" if you use the "O" command (not in insert mode!) | |
76 "e" if you type the second 'e' for an "else" at the start of a | |
77 line | |
78 | |
818 | 79 Characters that can precede each key: *i_CTRL-F* |
7 | 80 ! When a '!' precedes the key, Vim will not insert the key but will |
81 instead reindent the current line. This allows you to define a | |
82 command key for reindenting the current line. CTRL-F is the default | |
83 key for this. Be careful if you define CTRL-I for this because CTRL-I | |
84 is the ASCII code for <Tab>. | |
85 * When a '*' precedes the key, Vim will reindent the line before | |
86 inserting the key. If 'cinkeys' contains "*<Return>", Vim reindents | |
87 the current line before opening a new line. | |
88 0 When a zero precedes the key (but appears after '!' or '*') Vim will | |
89 reindent the line only if the key is the first character you type in | |
90 the line. When used before "=" Vim will only reindent the line if | |
91 there is only white space before the word. | |
92 | |
93 When neither '!' nor '*' precedes the key, Vim reindents the line after you | |
94 type the key. So ';' sets the indentation of a line which includes the ';'. | |
95 | |
96 Special key names: | |
97 <> Angle brackets mean spelled-out names of keys. For example: "<Up>", | |
98 "<Ins>" (see |key-notation|). | |
99 ^ Letters preceded by a caret (^) are control characters. For example: | |
100 "^F" is CTRL-F. | |
101 o Reindent a line when you use the "o" command or when Vim opens a new | |
102 line below the current one (e.g., when you type <Enter> in insert | |
103 mode). | |
104 O Reindent a line when you use the "O" command. | |
105 e Reindent a line that starts with "else" when you type the second 'e'. | |
106 : Reindent a line when a ':' is typed which is after a label or case | |
107 statement. Don't reindent for a ":" in "class::method" for C++. To | |
108 Reindent for any ":", use "<:>". | |
109 =word Reindent when typing the last character of "word". "word" may | |
110 actually be part of another word. Thus "=end" would cause reindenting | |
111 when typing the "d" in "endif" or "endwhile". But not when typing | |
112 "bend". Also reindent when completion produces a word that starts | |
113 with "word". "0=word" reindents when there is only white space before | |
114 the word. | |
115 =~word Like =word, but ignore case. | |
116 | |
117 If you really want to reindent when you type 'o', 'O', 'e', '0', '<', '>', | |
118 '*', ':' or '!', use "<o>", "<O>", "<e>", "<0>", "<<>", "<>>", "<*>", "<:>" or | |
119 "<!>", respectively, for those keys. | |
120 | |
121 For an emacs-style indent mode where lines aren't indented every time you | |
1247 | 122 press <Enter> but only if you press <Tab>, I suggest: |
7 | 123 :set cinkeys=0{,0},:,0#,!<Tab>,!^F |
124 You might also want to switch off 'autoindent' then. | |
125 | |
126 Note: If you change the current line's indentation manually, Vim ignores the | |
127 cindent settings for that line. This prevents vim from reindenting after you | |
128 have changed the indent by typing <BS>, <Tab>, or <Space> in the indent or | |
129 used CTRL-T or CTRL-D. | |
130 | |
131 *cinoptions-values* | |
2857 | 132 The 'cinoptions' option sets how Vim performs indentation. The value after |
133 the option character can be one of these (N is any number): | |
134 N indent N spaces | |
135 -N indent N spaces to the left | |
3082 | 136 Ns N times 'shiftwidth' spaces |
137 -Ns N times 'shiftwidth' spaces to the left | |
2857 | 138 |
139 In the list below, | |
7 | 140 "N" represents a number of your choice (the number can be negative). When |
141 there is an 's' after the number, Vim multiplies the number by 'shiftwidth': | |
142 "1s" is 'shiftwidth', "2s" is two times 'shiftwidth', etc. You can use a | |
2857 | 143 decimal point, too: "-0.5s" is minus half a 'shiftwidth'. |
144 The examples below assume a 'shiftwidth' of 4. | |
145 *cino->* | |
7 | 146 >N Amount added for "normal" indent. Used after a line that should |
147 increase the indent (lines starting with "if", an opening brace, | |
148 etc.). (default 'shiftwidth'). | |
149 | |
150 cino= cino=>2 cino=>2s > | |
151 if (cond) if (cond) if (cond) | |
152 { { { | |
153 foo; foo; foo; | |
154 } } } | |
155 < | |
2857 | 156 *cino-e* |
7 | 157 eN Add N to the prevailing indent inside a set of braces if the |
158 opening brace at the End of the line (more precise: is not the | |
159 first character in a line). This is useful if you want a | |
160 different indent when the '{' is at the start of the line from | |
161 when '{' is at the end of the line. (default 0). | |
162 | |
163 cino= cino=e2 cino=e-2 > | |
164 if (cond) { if (cond) { if (cond) { | |
165 foo; foo; foo; | |
166 } } } | |
167 else else else | |
168 { { { | |
169 bar; bar; bar; | |
170 } } } | |
171 < | |
2857 | 172 *cino-n* |
7 | 173 nN Add N to the prevailing indent for a statement after an "if", |
174 "while", etc., if it is NOT inside a set of braces. This is | |
175 useful if you want a different indent when there is no '{' | |
176 before the statement from when there is a '{' before it. | |
177 (default 0). | |
178 | |
179 cino= cino=n2 cino=n-2 > | |
180 if (cond) if (cond) if (cond) | |
181 foo; foo; foo; | |
182 else else else | |
183 { { { | |
184 bar; bar; bar; | |
185 } } } | |
186 < | |
2857 | 187 *cino-f* |
7 | 188 fN Place the first opening brace of a function or other block in |
189 column N. This applies only for an opening brace that is not | |
190 inside other braces and is at the start of the line. What comes | |
191 after the brace is put relative to this brace. (default 0). | |
192 | |
193 cino= cino=f.5s cino=f1s > | |
194 func() func() func() | |
195 { { { | |
196 int foo; int foo; int foo; | |
197 < | |
2857 | 198 *cino-{* |
7 | 199 {N Place opening braces N characters from the prevailing indent. |
200 This applies only for opening braces that are inside other | |
201 braces. (default 0). | |
202 | |
203 cino= cino={.5s cino={1s > | |
204 if (cond) if (cond) if (cond) | |
205 { { { | |
206 foo; foo; foo; | |
207 < | |
2857 | 208 *cino-}* |
7 | 209 }N Place closing braces N characters from the matching opening |
210 brace. (default 0). | |
211 | |
212 cino= cino={2,}-0.5s cino=}2 > | |
213 if (cond) if (cond) if (cond) | |
214 { { { | |
215 foo; foo; foo; | |
216 } } } | |
217 < | |
2857 | 218 *cino-^* |
7 | 219 ^N Add N to the prevailing indent inside a set of braces if the |
220 opening brace is in column 0. This can specify a different | |
221 indent for whole of a function (some may like to set it to a | |
222 negative number). (default 0). | |
223 | |
224 cino= cino=^-2 cino=^-s > | |
225 func() func() func() | |
226 { { { | |
227 if (cond) if (cond) if (cond) | |
228 { { { | |
229 a = b; a = b; a = b; | |
230 } } } | |
231 } } } | |
232 < | |
2857 | 233 *cino-L* |
2328
15379284e55a
Add the 'L' item to 'cinoptions'. (Manuel Konig)
Bram Moolenaar <bram@vim.org>
parents:
2297
diff
changeset
|
234 LN Controls placement of jump labels. If N is negative, the label |
15379284e55a
Add the 'L' item to 'cinoptions'. (Manuel Konig)
Bram Moolenaar <bram@vim.org>
parents:
2297
diff
changeset
|
235 will be placed at column 1. If N is non-negative, the indent of |
15379284e55a
Add the 'L' item to 'cinoptions'. (Manuel Konig)
Bram Moolenaar <bram@vim.org>
parents:
2297
diff
changeset
|
236 the label will be the prevailing indent minus N. (default -1). |
15379284e55a
Add the 'L' item to 'cinoptions'. (Manuel Konig)
Bram Moolenaar <bram@vim.org>
parents:
2297
diff
changeset
|
237 |
15379284e55a
Add the 'L' item to 'cinoptions'. (Manuel Konig)
Bram Moolenaar <bram@vim.org>
parents:
2297
diff
changeset
|
238 cino= cino=L2 cino=Ls > |
15379284e55a
Add the 'L' item to 'cinoptions'. (Manuel Konig)
Bram Moolenaar <bram@vim.org>
parents:
2297
diff
changeset
|
239 func() func() func() |
15379284e55a
Add the 'L' item to 'cinoptions'. (Manuel Konig)
Bram Moolenaar <bram@vim.org>
parents:
2297
diff
changeset
|
240 { { { |
15379284e55a
Add the 'L' item to 'cinoptions'. (Manuel Konig)
Bram Moolenaar <bram@vim.org>
parents:
2297
diff
changeset
|
241 { { { |
15379284e55a
Add the 'L' item to 'cinoptions'. (Manuel Konig)
Bram Moolenaar <bram@vim.org>
parents:
2297
diff
changeset
|
242 stmt; stmt; stmt; |
15379284e55a
Add the 'L' item to 'cinoptions'. (Manuel Konig)
Bram Moolenaar <bram@vim.org>
parents:
2297
diff
changeset
|
243 LABEL: LABEL: LABEL: |
15379284e55a
Add the 'L' item to 'cinoptions'. (Manuel Konig)
Bram Moolenaar <bram@vim.org>
parents:
2297
diff
changeset
|
244 } } } |
15379284e55a
Add the 'L' item to 'cinoptions'. (Manuel Konig)
Bram Moolenaar <bram@vim.org>
parents:
2297
diff
changeset
|
245 } } } |
15379284e55a
Add the 'L' item to 'cinoptions'. (Manuel Konig)
Bram Moolenaar <bram@vim.org>
parents:
2297
diff
changeset
|
246 < |
2857 | 247 *cino-:* |
7 | 248 :N Place case labels N characters from the indent of the switch(). |
249 (default 'shiftwidth'). | |
250 | |
251 cino= cino=:0 > | |
252 switch (x) switch(x) | |
253 { { | |
254 case 1: case 1: | |
255 a = b; a = b; | |
256 default: default: | |
257 } } | |
258 < | |
2857 | 259 *cino-=* |
7 | 260 =N Place statements occurring after a case label N characters from |
261 the indent of the label. (default 'shiftwidth'). | |
262 | |
263 cino= cino==10 > | |
264 case 11: case 11: a = a + 1; | |
265 a = a + 1; b = b + 1; | |
266 < | |
2857 | 267 *cino-l* |
7 | 268 lN If N != 0 Vim will align with a case label instead of the |
269 statement after it in the same line. | |
270 | |
271 cino= cino=l1 > | |
272 switch (a) { switch (a) { | |
273 case 1: { case 1: { | |
274 break; break; | |
275 } } | |
276 < | |
2857 | 277 *cino-b* |
7 | 278 bN If N != 0 Vim will align a final "break" with the case label, |
236 | 279 so that case..break looks like a sort of block. (default: 0). |
2662 | 280 When using 1, consider adding "0=break" to 'cinkeys'. |
7 | 281 |
282 cino= cino=b1 > | |
283 switch (x) switch(x) | |
284 { { | |
285 case 1: case 1: | |
286 a = b; a = b; | |
287 break; break; | |
288 | |
289 default: default: | |
290 a = 0; a = 0; | |
291 break; break; | |
292 } } | |
293 < | |
2857 | 294 *cino-g* |
7 | 295 gN Place C++ scope declarations N characters from the indent of the |
296 block they are in. (default 'shiftwidth'). A scope declaration | |
297 can be "public:", "protected:" or "private:". | |
298 | |
299 cino= cino=g0 > | |
300 { { | |
301 public: public: | |
302 a = b; a = b; | |
303 private: private: | |
304 } } | |
305 < | |
2857 | 306 *cino-h* |
7 | 307 hN Place statements occurring after a C++ scope declaration N |
308 characters from the indent of the label. (default | |
309 'shiftwidth'). | |
310 | |
311 cino= cino=h10 > | |
312 public: public: a = a + 1; | |
313 a = a + 1; b = b + 1; | |
314 < | |
2857 | 315 *cino-N* |
316 NN Indent inside C++ namespace N characters extra compared to a | |
317 normal block. (default 0). | |
318 | |
319 cino= cino=N-s > | |
320 namespace { namespace { | |
321 void function(); void function(); | |
322 } } | |
323 | |
324 namespace my namespace my | |
325 { { | |
326 void function(); void function(); | |
327 } } | |
328 < | |
11087
242e0617aa51
patch 8.0.0431: 'cinoptions' cannot set indent for extern block
Christian Brabandt <cb@256bit.org>
parents:
10198
diff
changeset
|
329 *cino-E* |
242e0617aa51
patch 8.0.0431: 'cinoptions' cannot set indent for extern block
Christian Brabandt <cb@256bit.org>
parents:
10198
diff
changeset
|
330 EN Indent inside C++ linkage specifications (extern "C" or |
242e0617aa51
patch 8.0.0431: 'cinoptions' cannot set indent for extern block
Christian Brabandt <cb@256bit.org>
parents:
10198
diff
changeset
|
331 extern "C++") N characters extra compared to a normal block. |
242e0617aa51
patch 8.0.0431: 'cinoptions' cannot set indent for extern block
Christian Brabandt <cb@256bit.org>
parents:
10198
diff
changeset
|
332 (default 0). |
242e0617aa51
patch 8.0.0431: 'cinoptions' cannot set indent for extern block
Christian Brabandt <cb@256bit.org>
parents:
10198
diff
changeset
|
333 |
242e0617aa51
patch 8.0.0431: 'cinoptions' cannot set indent for extern block
Christian Brabandt <cb@256bit.org>
parents:
10198
diff
changeset
|
334 cino= cino=E-s > |
242e0617aa51
patch 8.0.0431: 'cinoptions' cannot set indent for extern block
Christian Brabandt <cb@256bit.org>
parents:
10198
diff
changeset
|
335 extern "C" { extern "C" { |
242e0617aa51
patch 8.0.0431: 'cinoptions' cannot set indent for extern block
Christian Brabandt <cb@256bit.org>
parents:
10198
diff
changeset
|
336 void function(); void function(); |
242e0617aa51
patch 8.0.0431: 'cinoptions' cannot set indent for extern block
Christian Brabandt <cb@256bit.org>
parents:
10198
diff
changeset
|
337 } } |
242e0617aa51
patch 8.0.0431: 'cinoptions' cannot set indent for extern block
Christian Brabandt <cb@256bit.org>
parents:
10198
diff
changeset
|
338 |
242e0617aa51
patch 8.0.0431: 'cinoptions' cannot set indent for extern block
Christian Brabandt <cb@256bit.org>
parents:
10198
diff
changeset
|
339 extern "C" extern "C" |
242e0617aa51
patch 8.0.0431: 'cinoptions' cannot set indent for extern block
Christian Brabandt <cb@256bit.org>
parents:
10198
diff
changeset
|
340 { { |
242e0617aa51
patch 8.0.0431: 'cinoptions' cannot set indent for extern block
Christian Brabandt <cb@256bit.org>
parents:
10198
diff
changeset
|
341 void function(); void function(); |
242e0617aa51
patch 8.0.0431: 'cinoptions' cannot set indent for extern block
Christian Brabandt <cb@256bit.org>
parents:
10198
diff
changeset
|
342 } } |
242e0617aa51
patch 8.0.0431: 'cinoptions' cannot set indent for extern block
Christian Brabandt <cb@256bit.org>
parents:
10198
diff
changeset
|
343 < |
2857 | 344 *cino-p* |
7 | 345 pN Parameter declarations for K&R-style function declarations will |
346 be indented N characters from the margin. (default | |
347 'shiftwidth'). | |
348 | |
349 cino= cino=p0 cino=p2s > | |
350 func(a, b) func(a, b) func(a, b) | |
351 int a; int a; int a; | |
352 char b; char b; char b; | |
353 < | |
2857 | 354 *cino-t* |
7 | 355 tN Indent a function return type declaration N characters from the |
356 margin. (default 'shiftwidth'). | |
357 | |
358 cino= cino=t0 cino=t7 > | |
359 int int int | |
360 func() func() func() | |
361 < | |
2857 | 362 *cino-i* |
843 | 363 iN Indent C++ base class declarations and constructor |
7 | 364 initializations, if they start in a new line (otherwise they |
365 are aligned at the right side of the ':'). | |
366 (default 'shiftwidth'). | |
367 | |
368 cino= cino=i0 > | |
369 class MyClass : class MyClass : | |
370 public BaseClass public BaseClass | |
371 {} {} | |
372 MyClass::MyClass() : MyClass::MyClass() : | |
373 BaseClass(3) BaseClass(3) | |
374 {} {} | |
375 < | |
2857 | 376 *cino-+* |
2725 | 377 +N Indent a continuation line (a line that spills onto the next) |
378 inside a function N additional characters. (default | |
379 'shiftwidth'). | |
380 Outside of a function, when the previous line ended in a | |
381 backslash, the 2 * N is used. | |
7 | 382 |
383 cino= cino=+10 > | |
384 a = b + 9 * a = b + 9 * | |
385 c; c; | |
386 < | |
2857 | 387 *cino-c* |
7 | 388 cN Indent comment lines after the comment opener, when there is no |
389 other text with which to align, N characters from the comment | |
390 opener. (default 3). See also |format-comments|. | |
391 | |
392 cino= cino=c5 > | |
393 /* /* | |
394 text. text. | |
395 */ */ | |
396 < | |
2857 | 397 *cino-C* |
7 | 398 CN When N is non-zero, indent comment lines by the amount specified |
399 with the c flag above even if there is other text behind the | |
400 comment opener. (default 0). | |
401 | |
402 cino=c0 cino=c0,C1 > | |
403 /******** /******** | |
404 text. text. | |
405 ********/ ********/ | |
406 < (Example uses ":set comments& comments-=s1:/* comments^=s0:/*") | |
407 | |
2857 | 408 *cino-/* |
236 | 409 /N Indent comment lines N characters extra. (default 0). |
7 | 410 cino= cino=/4 > |
411 a = b; a = b; | |
412 /* comment */ /* comment */ | |
413 c = d; c = d; | |
414 < | |
2857 | 415 *cino-(* |
7 | 416 (N When in unclosed parentheses, indent N characters from the line |
417 with the unclosed parentheses. Add a 'shiftwidth' for every | |
13589 | 418 extra unclosed parentheses. When N is 0 or the unclosed |
419 parentheses is the first non-white character in its line, line | |
420 up with the next non-white character after the unclosed | |
421 parentheses. (default 'shiftwidth' * 2). | |
7 | 422 |
423 cino= cino=(0 > | |
424 if (c1 && (c2 || if (c1 && (c2 || | |
425 c3)) c3)) | |
426 foo; foo; | |
427 if (c1 && if (c1 && | |
428 (c2 || c3)) (c2 || c3)) | |
429 { { | |
430 < | |
2857 | 431 *cino-u* |
13589 | 432 uN Same as (N, but for one nesting level deeper. |
433 (default 'shiftwidth'). | |
7 | 434 |
435 cino= cino=u2 > | |
436 if (c123456789 if (c123456789 | |
437 && (c22345 && (c22345 | |
438 || c3)) || c3)) | |
439 < | |
2857 | 440 *cino-U* |
7 | 441 UN When N is non-zero, do not ignore the indenting specified by |
442 ( or u in case that the unclosed parentheses is the first | |
443 non-white character in its line. (default 0). | |
444 | |
445 cino= or cino=(s cino=(s,U1 > | |
446 c = c1 && c = c1 && | |
447 ( ( | |
448 c2 || c2 || | |
449 c3 c3 | |
450 ) && c4; ) && c4; | |
451 < | |
3082 | 452 *cino-w* |
7 | 453 wN When in unclosed parentheses and N is non-zero and either |
454 using "(0" or "u0", respectively, or using "U0" and the unclosed | |
455 parentheses is the first non-white character in its line, line | |
456 up with the character immediately after the unclosed parentheses | |
457 rather than the first non-white character. (default 0). | |
458 | |
459 cino=(0 cino=(0,w1 > | |
460 if ( c1 if ( c1 | |
461 && ( c2 && ( c2 | |
462 || c3)) || c3)) | |
463 foo; foo; | |
464 < | |
2857 | 465 *cino-W* |
7 | 466 WN When in unclosed parentheses and N is non-zero and either |
467 using "(0" or "u0", respectively and the unclosed parentheses is | |
468 the last non-white character in its line and it is not the | |
469 closing parentheses, indent the following line N characters | |
470 relative to the outer context (i.e. start of the line or the | |
236 | 471 next unclosed parentheses). (default: 0). |
7 | 472 |
473 cino=(0 cino=(0,W4 > | |
474 a_long_line( a_long_line( | |
475 argument, argument, | |
476 argument); argument); | |
477 a_short_line(argument, a_short_line(argument, | |
478 argument); argument); | |
479 < | |
3454 | 480 *cino-k* |
481 kN When in unclosed parentheses which follow "if", "for" or | |
482 "while" and N is non-zero, overrides the behaviour defined by | |
483 "(N": causes the indent to be N characters relative to the outer | |
484 context (i.e. the line where "if", "for" or "while" is). Has | |
485 no effect on deeper levels of nesting. Affects flags like "wN" | |
486 only for the "if", "for" and "while" conditions. If 0, defaults | |
487 to behaviour defined by the "(N" flag. (default: 0). | |
488 | |
489 cino=(0 cino=(0,ks > | |
490 if (condition1 if (condition1 | |
491 && condition2) && condition2) | |
492 action(); action(); | |
493 function(argument1 function(argument1 | |
494 && argument2); && argument2); | |
495 < | |
2857 | 496 *cino-m* |
7 | 497 mN When N is non-zero, line up a line starting with a closing |
498 parentheses with the first character of the line with the | |
499 matching opening parentheses. (default 0). | |
500 | |
501 cino=(s cino=(s,m1 > | |
502 c = c1 && ( c = c1 && ( | |
503 c2 || c2 || | |
504 c3 c3 | |
505 ) && c4; ) && c4; | |
506 if ( if ( | |
507 c1 && c2 c1 && c2 | |
508 ) ) | |
509 foo; foo; | |
510 < | |
2857 | 511 *cino-M* |
829 | 512 MN When N is non-zero, line up a line starting with a closing |
513 parentheses with the first character of the previous line. | |
514 (default 0). | |
515 | |
516 cino= cino=M1 > | |
517 if (cond1 && if (cond1 && | |
856 | 518 cond2 cond2 |
519 ) ) | |
829 | 520 < |
2857 | 521 *java-cinoptions* *java-indenting* *cino-j* |
2965 | 522 jN Indent Java anonymous classes correctly. Also works well for |
523 Javascript. The value 'N' is currently unused but must be | |
524 non-zero (e.g. 'j1'). 'j1' will indent for example the | |
525 following code snippet correctly: > | |
7 | 526 |
527 object.add(new ChangeListener() { | |
528 public void stateChanged(ChangeEvent e) { | |
529 do_something(); | |
530 } | |
531 }); | |
532 < | |
2857 | 533 *javascript-cinoptions* *javascript-indenting* *cino-J* |
2297
5ffe000a9ecf
Improve Javascript indenting. Add "J" flag to 'cino'. (Hari Kumar G)
Bram Moolenaar <bram@vim.org>
parents:
2278
diff
changeset
|
534 JN Indent JavaScript object declarations correctly by not confusing |
5ffe000a9ecf
Improve Javascript indenting. Add "J" flag to 'cino'. (Hari Kumar G)
Bram Moolenaar <bram@vim.org>
parents:
2278
diff
changeset
|
535 them with labels. The value 'N' is currently unused but must be |
2965 | 536 non-zero (e.g. 'J1'). If you enable this you probably also want |
537 to set |cino-j|. > | |
2297
5ffe000a9ecf
Improve Javascript indenting. Add "J" flag to 'cino'. (Hari Kumar G)
Bram Moolenaar <bram@vim.org>
parents:
2278
diff
changeset
|
538 |
5ffe000a9ecf
Improve Javascript indenting. Add "J" flag to 'cino'. (Hari Kumar G)
Bram Moolenaar <bram@vim.org>
parents:
2278
diff
changeset
|
539 var bar = { |
5ffe000a9ecf
Improve Javascript indenting. Add "J" flag to 'cino'. (Hari Kumar G)
Bram Moolenaar <bram@vim.org>
parents:
2278
diff
changeset
|
540 foo: { |
5ffe000a9ecf
Improve Javascript indenting. Add "J" flag to 'cino'. (Hari Kumar G)
Bram Moolenaar <bram@vim.org>
parents:
2278
diff
changeset
|
541 that: this, |
5ffe000a9ecf
Improve Javascript indenting. Add "J" flag to 'cino'. (Hari Kumar G)
Bram Moolenaar <bram@vim.org>
parents:
2278
diff
changeset
|
542 some: ok, |
5ffe000a9ecf
Improve Javascript indenting. Add "J" flag to 'cino'. (Hari Kumar G)
Bram Moolenaar <bram@vim.org>
parents:
2278
diff
changeset
|
543 }, |
5ffe000a9ecf
Improve Javascript indenting. Add "J" flag to 'cino'. (Hari Kumar G)
Bram Moolenaar <bram@vim.org>
parents:
2278
diff
changeset
|
544 "bar":{ |
5ffe000a9ecf
Improve Javascript indenting. Add "J" flag to 'cino'. (Hari Kumar G)
Bram Moolenaar <bram@vim.org>
parents:
2278
diff
changeset
|
545 a : 2, |
5ffe000a9ecf
Improve Javascript indenting. Add "J" flag to 'cino'. (Hari Kumar G)
Bram Moolenaar <bram@vim.org>
parents:
2278
diff
changeset
|
546 b: "123abc", |
5ffe000a9ecf
Improve Javascript indenting. Add "J" flag to 'cino'. (Hari Kumar G)
Bram Moolenaar <bram@vim.org>
parents:
2278
diff
changeset
|
547 x: 4, |
5ffe000a9ecf
Improve Javascript indenting. Add "J" flag to 'cino'. (Hari Kumar G)
Bram Moolenaar <bram@vim.org>
parents:
2278
diff
changeset
|
548 "y": 5 |
5ffe000a9ecf
Improve Javascript indenting. Add "J" flag to 'cino'. (Hari Kumar G)
Bram Moolenaar <bram@vim.org>
parents:
2278
diff
changeset
|
549 } |
5ffe000a9ecf
Improve Javascript indenting. Add "J" flag to 'cino'. (Hari Kumar G)
Bram Moolenaar <bram@vim.org>
parents:
2278
diff
changeset
|
550 } |
5ffe000a9ecf
Improve Javascript indenting. Add "J" flag to 'cino'. (Hari Kumar G)
Bram Moolenaar <bram@vim.org>
parents:
2278
diff
changeset
|
551 < |
2857 | 552 *cino-)* |
7 | 553 )N Vim searches for unclosed parentheses at most N lines away. |
554 This limits the time needed to search for parentheses. (default | |
555 20 lines). | |
556 | |
2857 | 557 *cino-star* |
7 | 558 *N Vim searches for unclosed comments at most N lines away. This |
559 limits the time needed to search for the start of a comment. | |
3830 | 560 If your /* */ comments stop indenting after N lines this is the |
2788 | 561 value you will want to change. |
2072 | 562 (default 70 lines). |
7 | 563 |
2857 | 564 *cino-#* |
5438 | 565 #N When N is non-zero recognize shell/Perl comments starting with |
566 '#', do not recognize preprocessor lines; allow right-shifting | |
567 lines that start with "#". | |
568 When N is zero (default): don't recognize '#' comments, do | |
569 recognize preprocessor lines; right-shifting lines that start | |
570 with "#" does not work. | |
1096 | 571 |
7 | 572 |
573 The defaults, spelled out in full, are: | |
11087
242e0617aa51
patch 8.0.0431: 'cinoptions' cannot set indent for extern block
Christian Brabandt <cb@256bit.org>
parents:
10198
diff
changeset
|
574 cinoptions=>s,e0,n0,f0,{0,}0,^0,L-1,:s,=s,l0,b0,gs,hs,N0,E0,ps,ts,is,+s, |
3454 | 575 c3,C0,/0,(2s,us,U0,w0,W0,k0,m0,j0,J0,)20,*70,#0 |
7 | 576 |
577 Vim puts a line in column 1 if: | |
5438 | 578 - It starts with '#' (preprocessor directives), if 'cinkeys' contains '#0'. |
7 | 579 - It starts with a label (a keyword followed by ':', other than "case" and |
2328
15379284e55a
Add the 'L' item to 'cinoptions'. (Manuel Konig)
Bram Moolenaar <bram@vim.org>
parents:
2297
diff
changeset
|
580 "default") and 'cinoptions' does not contain an 'L' entry with a positive |
15379284e55a
Add the 'L' item to 'cinoptions'. (Manuel Konig)
Bram Moolenaar <bram@vim.org>
parents:
2297
diff
changeset
|
581 value. |
7 | 582 - Any combination of indentations causes the line to have less than 0 |
583 indentation. | |
584 | |
585 ============================================================================== | |
586 2. Indenting by expression *indent-expression* | |
587 | |
588 The basics for using flexible indenting are explained in section |30.3| of the | |
589 user manual. | |
590 | |
591 If you want to write your own indent file, it must set the 'indentexpr' | |
14999 | 592 option. Setting the 'indentkeys' option is often useful. |
593 See the $VIMRUNTIME/indent/README.txt file for hints. | |
594 See the $VIMRUNTIME/indent directory for examples. | |
7 | 595 |
596 | |
597 REMARKS ABOUT SPECIFIC INDENT FILES ~ | |
598 | |
599 | |
4098 | 600 CLOJURE *ft-clojure-indent* *clojure-indent* |
601 | |
602 Clojure indentation differs somewhat from traditional Lisps, due in part to | |
603 the use of square and curly brackets, and otherwise by community convention. | |
5362
ab1508486b12
Update runtime files. Add support for J.
Bram Moolenaar <bram@vim.org>
parents:
5294
diff
changeset
|
604 These conventions are not universally followed, so the Clojure indent script |
ab1508486b12
Update runtime files. Add support for J.
Bram Moolenaar <bram@vim.org>
parents:
5294
diff
changeset
|
605 offers a few configurable options, listed below. |
4098 | 606 |
15033 | 607 If the current vim does not include |searchpairpos()|, the indent script falls |
4098 | 608 back to normal 'lisp' indenting, and the following options are ignored. |
609 | |
610 *g:clojure_maxlines* | |
611 | |
15033 | 612 Set maximum scan distance of |searchpairpos()|. Larger values trade |
613 performance for correctness when dealing with very long forms. A value of 0 | |
614 will scan without limits. | |
4098 | 615 > |
616 " Default | |
617 let g:clojure_maxlines = 100 | |
618 < | |
619 *g:clojure_fuzzy_indent* | |
620 *g:clojure_fuzzy_indent_patterns* | |
621 *g:clojure_fuzzy_indent_blacklist* | |
622 | |
623 The 'lispwords' option is a list of comma-separated words that mark special | |
624 forms whose subforms must be indented with two spaces. | |
625 | |
626 For example: | |
627 > | |
628 (defn bad [] | |
629 "Incorrect indentation") | |
630 | |
631 (defn good [] | |
632 "Correct indentation") | |
633 < | |
634 If you would like to specify 'lispwords' with a |pattern| instead, you can use | |
635 the fuzzy indent feature: | |
636 > | |
637 " Default | |
638 let g:clojure_fuzzy_indent = 1 | |
639 let g:clojure_fuzzy_indent_patterns = ['^with', '^def', '^let'] | |
640 let g:clojure_fuzzy_indent_blacklist = | |
641 \ ['-fn$', '\v^with-%(meta|out-str|loading-context)$'] | |
642 | |
643 " Legacy comma-delimited string version; the list format above is | |
644 " recommended. Note that patterns are implicitly anchored with ^ and $ | |
645 let g:clojure_fuzzy_indent_patterns = 'with.*,def.*,let.*' | |
646 < | |
647 |g:clojure_fuzzy_indent_patterns| and |g:clojure_fuzzy_indent_blacklist| are | |
648 |Lists| of patterns that will be matched against the unquoted, unqualified | |
649 symbol at the head of a list. This means that a pattern like "^foo" will match | |
650 all these candidates: "foobar", "my.ns/foobar", and "#'foobar". | |
651 | |
652 Each candidate word is tested for special treatment in this order: | |
653 | |
654 1. Return true if word is literally in 'lispwords' | |
655 2. Return false if word matches a pattern in | |
656 |g:clojure_fuzzy_indent_blacklist| | |
657 3. Return true if word matches a pattern in | |
658 |g:clojure_fuzzy_indent_patterns| | |
659 4. Return false and indent normally otherwise | |
660 | |
661 *g:clojure_special_indent_words* | |
662 | |
663 Some forms in Clojure are indented so that every subform is indented only two | |
664 spaces, regardless of 'lispwords'. If you have a custom construct that should | |
665 be indented in this idiosyncratic fashion, you can add your symbols to the | |
666 default list below. | |
667 > | |
668 " Default | |
669 let g:clojure_special_indent_words = | |
670 \ 'deftype,defrecord,reify,proxy,extend-type,extend-protocol,letfn' | |
671 < | |
672 *g:clojure_align_multiline_strings* | |
673 | |
674 Align subsequent lines in multiline strings to the column after the opening | |
675 quote, instead of the same column. | |
676 | |
677 For example: | |
678 > | |
679 (def default | |
680 "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do | |
681 eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut | |
682 enim ad minim veniam, quis nostrud exercitation ullamco laboris | |
683 nisi ut aliquip ex ea commodo consequat.") | |
684 | |
685 (def aligned | |
686 "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do | |
687 eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut | |
688 enim ad minim veniam, quis nostrud exercitation ullamco laboris | |
689 nisi ut aliquip ex ea commodo consequat.") | |
690 < | |
691 This option is off by default. | |
692 > | |
693 " Default | |
694 let g:clojure_align_multiline_strings = 0 | |
695 < | |
5577 | 696 *g:clojure_align_subforms* |
697 | |
698 By default, parenthesized compound forms that look like function calls and | |
699 whose head subform is on its own line have subsequent subforms indented by | |
700 two spaces relative to the opening paren: | |
701 > | |
702 (foo | |
703 bar | |
704 baz) | |
705 < | |
706 Setting this option changes this behavior so that all subforms are aligned to | |
5763 | 707 the same column, emulating the default behavior of clojure-mode.el: |
5577 | 708 > |
709 (foo | |
710 bar | |
711 baz) | |
712 < | |
713 This option is off by default. | |
714 > | |
715 " Default | |
716 let g:clojure_align_subforms = 0 | |
717 < | |
4098 | 718 |
501 | 719 FORTRAN *ft-fortran-indent* |
7 | 720 |
2908 | 721 Block if, select case, where, and forall constructs are indented. So are |
722 type, interface, associate, block, and enum constructs. The indenting of | |
723 subroutines, functions, modules, and program blocks is optional. Comments, | |
724 labelled statements and continuation lines are indented if the Fortran is in | |
725 free source form, whereas they are not indented if the Fortran is in fixed | |
726 source form because of the left margin requirements. Hence manual indent | |
727 corrections will be necessary for labelled statements and continuation lines | |
728 when fixed source form is being used. For further discussion of the method | |
729 used for the detection of source format see |ft-fortran-syntax|. | |
7 | 730 |
731 Do loops ~ | |
236 | 732 All do loops are left unindented by default. Do loops can be unstructured in |
7 | 733 Fortran with (possibly multiple) loops ending on a labelled executable |
236 | 734 statement of almost arbitrary type. Correct indentation requires |
735 compiler-quality parsing. Old code with do loops ending on labelled statements | |
7 | 736 of arbitrary type can be indented with elaborate programs such as Tidy |
236 | 737 (http://www.unb.ca/chem/ajit/f_tidy.htm). Structured do/continue loops are |
7 | 738 also left unindented because continue statements are also used for purposes |
236 | 739 other than ending a do loop. Programs such as Tidy can convert structured |
740 do/continue loops to the do/enddo form. Do loops of the do/enddo variety can | |
741 be indented. If you use only structured loops of the do/enddo form, you should | |
7 | 742 declare this by setting the fortran_do_enddo variable in your .vimrc as |
743 follows > | |
744 | |
745 let fortran_do_enddo=1 | |
746 | |
236 | 747 in which case do loops will be indented. If all your loops are of do/enddo |
7 | 748 type only in, say, .f90 files, then you should set a buffer flag with an |
749 autocommand such as > | |
750 | |
751 au! BufRead,BufNewFile *.f90 let b:fortran_do_enddo=1 | |
752 | |
753 to get do loops indented in .f90 files and left alone in Fortran files with | |
754 other extensions such as .for. | |
755 | |
2908 | 756 Program units ~ |
757 The indenting of program units (subroutines, functions, modules, and program | |
758 blocks) is enabled by default but can be suppressed if a lighter, screen-width | |
759 preserving indent style is desired. To suppress the indenting of program | |
760 units for all fortran files set the global fortran_indent_less variable in | |
761 your .vimrc as follows > | |
762 | |
763 let fortran_indent_less=1 | |
764 | |
765 A finer level of suppression can be achieved by setting the corresponding | |
766 buffer-local variable as follows > | |
767 | |
768 let b:fortran_indent_less=1 | |
769 | |
7 | 770 |
4869 | 771 HTML *ft-html-indent* *html-indent* *html-indenting* |
772 | |
773 This is about variables you can set in your vimrc to customize HTML indenting. | |
774 | |
775 You can set the indent for the first line after <script> and <style> | |
776 "blocktags" (default "zero"): > | |
777 | |
778 :let g:html_indent_script1 = "inc" | |
779 :let g:html_indent_style1 = "inc" | |
780 < | |
781 VALUE MEANING ~ | |
782 "zero" zero indent | |
783 "auto" auto indent (same indent as the blocktag) | |
784 "inc" auto indent + one indent step | |
785 | |
786 Many tags increase the indent for what follows per default (see "Add Indent | |
4911 | 787 Tags" in the script). You can add further tags with: > |
4869 | 788 |
789 :let g:html_indent_inctags = "html,body,head,tbody" | |
790 | |
791 You can also remove such tags with: > | |
792 | |
793 :let g:html_indent_autotags = "th,td,tr,tfoot,thead" | |
794 | |
795 Default value is empty for both variables. Note: the initial "inctags" are | |
796 only defined once per Vim session. | |
797 | |
798 User variables are only read when the script is sourced. To enable your | |
4911 | 799 changes during a session, without reloading the HTML file, you can manually |
4869 | 800 do: > |
801 | |
802 :call HtmlIndent_CheckUserSettings() | |
803 | |
804 Detail: | |
805 Calculation of indent inside "blocktags" with "alien" content: | |
806 BLOCKTAG INDENT EXPR WHEN APPLICABLE ~ | |
4911 | 807 <script> : {customizable} if first line of block |
808 : cindent(v:lnum) if attributes empty or contain "java" | |
809 : -1 else (vbscript, tcl, ...) | |
810 <style> : {customizable} if first line of block | |
811 : GetCSSIndent() else | |
4869 | 812 <!-- --> : -1 |
813 | |
814 | |
1668 | 815 PHP *ft-php-indent* *php-indent* *php-indenting* |
816 | |
817 NOTE: PHP files will be indented correctly only if PHP |syntax| is active. | |
818 | |
819 If you are editing a file in Unix 'fileformat' and '\r' characters are present | |
820 before new lines, indentation won't proceed correctly ; you have to remove | |
821 those useless characters first with a command like: > | |
822 | |
823 :%s /\r$//g | |
824 | |
825 Or, you can simply |:let| the variable PHP_removeCRwhenUnix to 1 and the | |
4502
605c9ce57ec3
Updated runtime files, language files and translations.
Bram Moolenaar <bram@vim.org>
parents:
4098
diff
changeset
|
826 script will silently remove them when Vim loads a PHP file (at each |BufRead|). |
1668 | 827 |
828 OPTIONS: ~ | |
829 | |
830 PHP indenting can be altered in several ways by modifying the values of some | |
4502
605c9ce57ec3
Updated runtime files, language files and translations.
Bram Moolenaar <bram@vim.org>
parents:
4098
diff
changeset
|
831 global variables: |
1668 | 832 |
5862 | 833 *php-comment* *PHP_autoformatcomment* |
9407
619a98a67f67
commit https://github.com/vim/vim/commit/e18dbe865d190e74fb5d43ac8bc6ac22507d0223
Christian Brabandt <cb@256bit.org>
parents:
6421
diff
changeset
|
834 To not enable auto-formatting of comments by default (if you want to use your |
1668 | 835 own 'formatoptions'): > |
836 :let g:PHP_autoformatcomment = 0 | |
837 | |
838 Else, 't' will be removed from the 'formatoptions' string and "qrowcb" will be | |
4502
605c9ce57ec3
Updated runtime files, language files and translations.
Bram Moolenaar <bram@vim.org>
parents:
4098
diff
changeset
|
839 added, see |fo-table| for more information. |
1668 | 840 ------------- |
841 | |
5862 | 842 *PHP_outdentSLComments* |
4502
605c9ce57ec3
Updated runtime files, language files and translations.
Bram Moolenaar <bram@vim.org>
parents:
4098
diff
changeset
|
843 To add extra indentation to single-line comments: > |
605c9ce57ec3
Updated runtime files, language files and translations.
Bram Moolenaar <bram@vim.org>
parents:
4098
diff
changeset
|
844 :let g:PHP_outdentSLComments = N |
605c9ce57ec3
Updated runtime files, language files and translations.
Bram Moolenaar <bram@vim.org>
parents:
4098
diff
changeset
|
845 |
605c9ce57ec3
Updated runtime files, language files and translations.
Bram Moolenaar <bram@vim.org>
parents:
4098
diff
changeset
|
846 With N being the number of 'shiftwidth' to add. |
605c9ce57ec3
Updated runtime files, language files and translations.
Bram Moolenaar <bram@vim.org>
parents:
4098
diff
changeset
|
847 |
605c9ce57ec3
Updated runtime files, language files and translations.
Bram Moolenaar <bram@vim.org>
parents:
4098
diff
changeset
|
848 Only single-line comments will be affected such as: > |
605c9ce57ec3
Updated runtime files, language files and translations.
Bram Moolenaar <bram@vim.org>
parents:
4098
diff
changeset
|
849 # Comment |
605c9ce57ec3
Updated runtime files, language files and translations.
Bram Moolenaar <bram@vim.org>
parents:
4098
diff
changeset
|
850 // Comment |
605c9ce57ec3
Updated runtime files, language files and translations.
Bram Moolenaar <bram@vim.org>
parents:
4098
diff
changeset
|
851 /* Comment */ |
605c9ce57ec3
Updated runtime files, language files and translations.
Bram Moolenaar <bram@vim.org>
parents:
4098
diff
changeset
|
852 ------------- |
605c9ce57ec3
Updated runtime files, language files and translations.
Bram Moolenaar <bram@vim.org>
parents:
4098
diff
changeset
|
853 |
5862 | 854 *PHP_default_indenting* |
4502
605c9ce57ec3
Updated runtime files, language files and translations.
Bram Moolenaar <bram@vim.org>
parents:
4098
diff
changeset
|
855 To add extra indentation to every PHP lines with N being the number of |
1668 | 856 'shiftwidth' to add: > |
857 :let g:PHP_default_indenting = N | |
858 | |
859 For example, with N = 1, this will give: | |
860 > | |
861 <?php | |
862 if (!isset($History_lst_sel)) | |
863 if (!isset($History_lst_sel)) | |
864 if (!isset($History_lst_sel)) { | |
865 $History_lst_sel=0; | |
866 } else | |
867 $foo="bar"; | |
868 | |
869 $command_hist = TRUE; | |
870 ?> | |
4502
605c9ce57ec3
Updated runtime files, language files and translations.
Bram Moolenaar <bram@vim.org>
parents:
4098
diff
changeset
|
871 (Notice the extra indentation between the PHP container markers and the code) |
1668 | 872 ------------- |
873 | |
5862 | 874 *PHP_outdentphpescape* |
875 To indent PHP escape tags as the surrounding non-PHP code (only affects the | |
876 PHP escape tags): > | |
877 :let g:PHP_outdentphpescape = 0 | |
2442 | 878 ------------- |
879 | |
5862 | 880 *PHP_removeCRwhenUnix* |
1668 | 881 To automatically remove '\r' characters when the 'fileformat' is set to Unix: > |
882 :let g:PHP_removeCRwhenUnix = 1 | |
883 ------------- | |
884 | |
5862 | 885 *PHP_BracesAtCodeLevel* |
1668 | 886 To indent braces at the same level than the code they contain: > |
887 :let g:PHP_BracesAtCodeLevel = 1 | |
888 | |
889 This will give the following result: > | |
890 if ($foo) | |
891 { | |
892 foo(); | |
893 } | |
894 Instead of: > | |
895 if ($foo) | |
896 { | |
897 foo(); | |
898 } | |
899 | |
900 NOTE: Indenting will be a bit slower if this option is used because some | |
901 optimizations won't be available. | |
902 ------------- | |
903 | |
5862 | 904 *PHP_vintage_case_default_indent* |
1668 | 905 To indent 'case:' and 'default:' statements in switch() blocks: > |
906 :let g:PHP_vintage_case_default_indent = 1 | |
907 | |
4502
605c9ce57ec3
Updated runtime files, language files and translations.
Bram Moolenaar <bram@vim.org>
parents:
4098
diff
changeset
|
908 In PHP braces are not required inside 'case/default' blocks therefore 'case:' |
605c9ce57ec3
Updated runtime files, language files and translations.
Bram Moolenaar <bram@vim.org>
parents:
4098
diff
changeset
|
909 and 'default:' are indented at the same level than the 'switch()' to avoid |
605c9ce57ec3
Updated runtime files, language files and translations.
Bram Moolenaar <bram@vim.org>
parents:
4098
diff
changeset
|
910 meaningless indentation. You can use the above option to return to the |
605c9ce57ec3
Updated runtime files, language files and translations.
Bram Moolenaar <bram@vim.org>
parents:
4098
diff
changeset
|
911 traditional way. |
14006 | 912 ------------- |
913 | |
914 *PHP_noArrowMatching* | |
915 By default the indent script will indent multi-line chained calls by matching | |
916 the position of the '->': > | |
917 | |
918 $user_name_very_long->name() | |
919 ->age() | |
920 ->info(); | |
921 | |
922 You can revert to the classic way of indenting by setting this option to 1: > | |
923 :let g:PHP_noArrowMatching = 1 | |
924 | |
925 You will obtain the following result: > | |
926 | |
927 $user_name_very_long->name() | |
928 ->age() | |
929 ->info(); | |
930 | |
1668 | 931 |
932 | |
501 | 933 PYTHON *ft-python-indent* |
170 | 934 |
935 The amount of indent can be set for the following situations. The examples | |
1698 | 936 given are the defaults. Note that the variables are set to an expression, so |
937 that you can change the value of 'shiftwidth' later. | |
170 | 938 |
939 Indent after an open paren: > | |
15033 | 940 let g:pyindent_open_paren = 'shiftwidth() * 2' |
170 | 941 Indent after a nested paren: > |
15033 | 942 let g:pyindent_nested_paren = 'shiftwidth()' |
170 | 943 Indent for a continuation line: > |
15033 | 944 let g:pyindent_continue = 'shiftwidth() * 2' |
170 | 945 |
15033 | 946 The method uses |searchpair()| to look back for unclosed parenthesis. This |
947 can sometimes be slow, thus it timeouts after 150 msec. If you notice the | |
14945 | 948 indenting isn't correct, you can set a larger timeout in msec: > |
949 let g:pyindent_searchpair_timeout = 500 | |
950 | |
15932 | 951 If looking back for unclosed parenthesis is still too slow, especially during |
952 a copy-paste operation, or if you don't need indenting inside multi-line | |
953 parentheses, you can completely disable this feature: > | |
954 let g:pyindent_disable_parentheses_indenting = 1 | |
955 | |
170 | 956 |
3082 | 957 R *ft-r-indent* |
958 | |
959 Function arguments are aligned if they span for multiple lines. If you prefer | |
960 do not have the arguments of functions aligned, put in your |vimrc|: | |
961 > | |
962 let r_indent_align_args = 0 | |
963 < | |
964 All lines beginning with a comment character, #, get the same indentation | |
965 level of the normal R code. Users of Emacs/ESS may be used to have lines | |
966 beginning with a single # indented in the 40th column, ## indented as R code, | |
967 and ### not indented. If you prefer that lines beginning with comment | |
968 characters are aligned as they are by Emacs/ESS, put in your |vimrc|: | |
969 > | |
970 let r_indent_ess_comments = 1 | |
971 < | |
972 If you prefer that lines beginning with a single # are aligned at a column | |
973 different from the 40th one, you should set a new value to the variable | |
974 r_indent_comment_column, as in the example below: | |
975 > | |
976 let r_indent_comment_column = 30 | |
977 < | |
978 Any code after a line that ends with "<-" is indented. Emacs/ESS does not | |
979 indent the code if it is a top level function. If you prefer that the | |
980 Vim-R-plugin behaves like Emacs/ESS in this regard, put in your |vimrc|: | |
981 > | |
982 let r_indent_ess_compatible = 1 | |
983 < | |
984 Below is an example of indentation with and without this option enabled: | |
985 > | |
986 ### r_indent_ess_compatible = 1 ### r_indent_ess_compatible = 0 | |
987 foo <- foo <- | |
988 function(x) function(x) | |
989 { { | |
990 paste(x) paste(x) | |
991 } } | |
992 < | |
14637 | 993 The code will be indented after lines that match the pattern |
994 `'\(&\||\|+\|-\|\*\|/\|=\|\~\|%\|->\)\s*$'`. If you want indentation after | |
995 lines that match a different pattern, you should set the appropriate value of | |
996 `r_indent_op_pattern` in your |vimrc|. | |
997 | |
3082 | 998 |
1201 | 999 SHELL *ft-sh-indent* |
1000 | |
1001 The amount of indent applied under various circumstances in a shell file can | |
1002 be configured by setting the following keys in the |Dictionary| | |
1003 b:sh_indent_defaults to a specific amount or to a |Funcref| that references a | |
1004 function that will return the amount desired: | |
1005 | |
1006 b:sh_indent_options['default'] Default amount of indent. | |
1007 | |
1008 b:sh_indent_options['continuation-line'] | |
1009 Amount of indent to add to a continued line. | |
1010 | |
1011 b:sh_indent_options['case-labels'] | |
1012 Amount of indent to add for case labels. | |
2033
de5a43c5eedc
Update documentation files.
Bram Moolenaar <bram@zimbu.org>
parents:
1702
diff
changeset
|
1013 (not actually implemented) |
1201 | 1014 |
2033
de5a43c5eedc
Update documentation files.
Bram Moolenaar <bram@zimbu.org>
parents:
1702
diff
changeset
|
1015 b:sh_indent_options['case-statements'] |
1201 | 1016 Amount of indent to add for case statements. |
1017 | |
1018 b:sh_indent_options['case-breaks'] | |
1019 Amount of indent to add (or more likely | |
1020 remove) for case breaks. | |
1021 | |
501 | 1022 VERILOG *ft-verilog-indent* |
7 | 1023 |
1024 General block statements such as if, for, case, always, initial, function, | |
1025 specify and begin, etc., are indented. The module block statements (first | |
1026 level blocks) are not indented by default. you can turn on the indent with | |
1027 setting a variable in the .vimrc as follows: > | |
1028 | |
1029 let b:verilog_indent_modules = 1 | |
1030 | |
1031 then the module blocks will be indented. To stop this, remove the variable: > | |
1032 | |
1033 :unlet b:verilog_indent_modules | |
1034 | |
1035 To set the variable only for Verilog file. The following statements can be | |
1036 used: > | |
1037 | |
1038 au BufReadPost * if exists("b:current_syntax") | |
1039 au BufReadPost * if b:current_syntax == "verilog" | |
1040 au BufReadPost * let b:verilog_indent_modules = 1 | |
1041 au BufReadPost * endif | |
1042 au BufReadPost * endif | |
1043 | |
1044 Furthermore, setting the variable b:verilog_indent_width to change the | |
1045 indenting width (default is 'shiftwidth'): > | |
1046 | |
1047 let b:verilog_indent_width = 4 | |
15033 | 1048 let b:verilog_indent_width = shiftwidth() * 2 |
7 | 1049 |
1050 In addition, you can turn the verbose mode for debug issue: > | |
1051 | |
1052 let b:verilog_indent_verbose = 1 | |
1053 | |
1054 Make sure to do ":set cmdheight=2" first to allow the display of the message. | |
1055 | |
22 | 1056 |
1620 | 1057 VHDL *ft-vhdl-indent* |
1058 | |
1059 Alignment of generic/port mapping statements are performed by default. This | |
1060 causes the following alignment example: > | |
1061 | |
1062 ENTITY sync IS | |
1063 PORT ( | |
1064 clk : IN STD_LOGIC; | |
1065 reset_n : IN STD_LOGIC; | |
1066 data_input : IN STD_LOGIC; | |
1067 data_out : OUT STD_LOGIC | |
1068 ); | |
1069 END ENTITY sync; | |
1070 | |
1071 To turn this off, add > | |
1072 | |
1073 let g:vhdl_indent_genportmap = 0 | |
1074 | |
1075 to the .vimrc file, which causes the previous alignment example to change: > | |
1076 | |
1077 ENTITY sync IS | |
1078 PORT ( | |
1079 clk : IN STD_LOGIC; | |
1080 reset_n : IN STD_LOGIC; | |
1081 data_input : IN STD_LOGIC; | |
1082 data_out : OUT STD_LOGIC | |
1083 ); | |
1084 END ENTITY sync; | |
1085 | |
1086 ---------------------------------------- | |
1087 | |
1088 Alignment of right-hand side assignment "<=" statements are performed by | |
1089 default. This causes the following alignment example: > | |
1090 | |
1091 sig_out <= (bus_a(1) AND | |
1092 (sig_b OR sig_c)) OR | |
1093 (bus_a(0) AND sig_d); | |
1094 | |
1095 To turn this off, add > | |
1096 | |
1097 let g:vhdl_indent_rhsassign = 0 | |
1098 | |
1099 to the .vimrc file, which causes the previous alignment example to change: > | |
1100 | |
1101 sig_out <= (bus_a(1) AND | |
1102 (sig_b OR sig_c)) OR | |
1103 (bus_a(0) AND sig_d); | |
1104 | |
1105 ---------------------------------------- | |
1106 | |
1107 Full-line comments (lines that begin with "--") are indented to be aligned with | |
1108 the very previous line's comment, PROVIDED that a whitespace follows after | |
1109 "--". | |
1110 | |
1111 For example: > | |
1112 | |
1113 sig_a <= sig_b; -- start of a comment | |
1114 -- continuation of the comment | |
1115 -- more of the same comment | |
1116 | |
1117 While in Insert mode, after typing "-- " (note the space " "), hitting CTRL-F | |
1118 will align the current "-- " with the previous line's "--". | |
1119 | |
1120 If the very previous line does not contain "--", THEN the full-line comment | |
1121 will be aligned with the start of the next non-blank line that is NOT a | |
1122 full-line comment. | |
1123 | |
1124 Indenting the following code: > | |
1125 | |
1126 sig_c <= sig_d; -- comment 0 | |
1127 -- comment 1 | |
1128 -- comment 2 | |
1129 --debug_code: | |
1130 --PROCESS(debug_in) | |
1131 --BEGIN | |
1132 -- FOR i IN 15 DOWNTO 0 LOOP | |
1133 -- debug_out(8*i+7 DOWNTO 8*i) <= debug_in(15-i); | |
1134 -- END LOOP; | |
1135 --END PROCESS debug_code; | |
1136 | |
1137 -- comment 3 | |
1138 sig_e <= sig_f; -- comment 4 | |
1139 -- comment 5 | |
1140 | |
1141 results in: > | |
1142 | |
1143 sig_c <= sig_d; -- comment 0 | |
1144 -- comment 1 | |
1145 -- comment 2 | |
1146 --debug_code: | |
1147 --PROCESS(debug_in) | |
1148 --BEGIN | |
1149 -- FOR i IN 15 DOWNTO 0 LOOP | |
1150 -- debug_out(8*i+7 DOWNTO 8*i) <= debug_in(15-i); | |
1151 -- END LOOP; | |
1152 --END PROCESS debug_code; | |
1153 | |
1154 -- comment 3 | |
1155 sig_e <= sig_f; -- comment 4 | |
1156 -- comment 5 | |
1157 | |
1158 Notice that "--debug_code:" does not align with "-- comment 2" | |
1159 because there is no whitespace that follows after "--" in "--debug_code:". | |
1160 | |
1161 Given the dynamic nature of indenting comments, indenting should be done TWICE. | |
1162 On the first pass, code will be indented. On the second pass, full-line | |
1163 comments will be indented according to the correctly indented code. | |
1164 | |
1165 | |
501 | 1166 VIM *ft-vim-indent* |
22 | 1167 |
1168 For indenting Vim scripts there is one variable that specifies the amount of | |
1169 indent for a continuation line, a line that starts with a backslash: > | |
1170 | |
15033 | 1171 :let g:vim_indent_cont = shiftwidth() * 3 |
22 | 1172 |
1173 Three times shiftwidth is the default value. | |
1174 | |
1175 | |
14421 | 1176 vim:tw=78:ts=8:noet:ft=help:norl: |