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