comparison runtime/doc/indent.txt @ 2857:f80e67bd6271 v7.3.202

updated for version 7.3.202 Problem: Cannot influence the indent inside a namespace. Solution: Add the "N" 'cino' parameter. (Konstantin Lepa)
author Bram Moolenaar <bram@vim.org>
date Wed, 25 May 2011 15:16:18 +0200
parents 0877b8d6370e
children fd09a9c8468e
comparison
equal deleted inserted replaced
2856:09fc31c1082e 2857:f80e67bd6271
126 cindent settings for that line. This prevents vim from reindenting after you 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 127 have changed the indent by typing <BS>, <Tab>, or <Space> in the indent or
128 used CTRL-T or CTRL-D. 128 used CTRL-T or CTRL-D.
129 129
130 *cinoptions-values* 130 *cinoptions-values*
131 The 'cinoptions' option sets how Vim performs indentation. In the list below, 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
135 Ns N times 'shiftwidth spaces
136 -Ns N times 'shiftwidth spaces to the left
137
138 In the list below,
132 "N" represents a number of your choice (the number can be negative). When 139 "N" represents a number of your choice (the number can be negative). When
133 there is an 's' after the number, Vim multiplies the number by 'shiftwidth': 140 there is an 's' after the number, Vim multiplies the number by 'shiftwidth':
134 "1s" is 'shiftwidth', "2s" is two times 'shiftwidth', etc. You can use a 141 "1s" is 'shiftwidth', "2s" is two times 'shiftwidth', etc. You can use a
135 decimal point, too: "-0.5s" is minus half a 'shiftwidth'. The examples below 142 decimal point, too: "-0.5s" is minus half a 'shiftwidth'.
136 assume a 'shiftwidth' of 4. 143 The examples below assume a 'shiftwidth' of 4.
137 144 *cino->*
138 >N Amount added for "normal" indent. Used after a line that should 145 >N Amount added for "normal" indent. Used after a line that should
139 increase the indent (lines starting with "if", an opening brace, 146 increase the indent (lines starting with "if", an opening brace,
140 etc.). (default 'shiftwidth'). 147 etc.). (default 'shiftwidth').
141 148
142 cino= cino=>2 cino=>2s > 149 cino= cino=>2 cino=>2s >
143 if (cond) if (cond) if (cond) 150 if (cond) if (cond) if (cond)
144 { { { 151 { { {
145 foo; foo; foo; 152 foo; foo; foo;
146 } } } 153 } } }
147 < 154 <
155 *cino-e*
148 eN Add N to the prevailing indent inside a set of braces if the 156 eN Add N to the prevailing indent inside a set of braces if the
149 opening brace at the End of the line (more precise: is not the 157 opening brace at the End of the line (more precise: is not the
150 first character in a line). This is useful if you want a 158 first character in a line). This is useful if you want a
151 different indent when the '{' is at the start of the line from 159 different indent when the '{' is at the start of the line from
152 when '{' is at the end of the line. (default 0). 160 when '{' is at the end of the line. (default 0).
158 else else else 166 else else else
159 { { { 167 { { {
160 bar; bar; bar; 168 bar; bar; bar;
161 } } } 169 } } }
162 < 170 <
171 *cino-n*
163 nN Add N to the prevailing indent for a statement after an "if", 172 nN Add N to the prevailing indent for a statement after an "if",
164 "while", etc., if it is NOT inside a set of braces. This is 173 "while", etc., if it is NOT inside a set of braces. This is
165 useful if you want a different indent when there is no '{' 174 useful if you want a different indent when there is no '{'
166 before the statement from when there is a '{' before it. 175 before the statement from when there is a '{' before it.
167 (default 0). 176 (default 0).
172 else else else 181 else else else
173 { { { 182 { { {
174 bar; bar; bar; 183 bar; bar; bar;
175 } } } 184 } } }
176 < 185 <
186 *cino-f*
177 fN Place the first opening brace of a function or other block in 187 fN Place the first opening brace of a function or other block in
178 column N. This applies only for an opening brace that is not 188 column N. This applies only for an opening brace that is not
179 inside other braces and is at the start of the line. What comes 189 inside other braces and is at the start of the line. What comes
180 after the brace is put relative to this brace. (default 0). 190 after the brace is put relative to this brace. (default 0).
181 191
182 cino= cino=f.5s cino=f1s > 192 cino= cino=f.5s cino=f1s >
183 func() func() func() 193 func() func() func()
184 { { { 194 { { {
185 int foo; int foo; int foo; 195 int foo; int foo; int foo;
186 < 196 <
197 *cino-{*
187 {N Place opening braces N characters from the prevailing indent. 198 {N Place opening braces N characters from the prevailing indent.
188 This applies only for opening braces that are inside other 199 This applies only for opening braces that are inside other
189 braces. (default 0). 200 braces. (default 0).
190 201
191 cino= cino={.5s cino={1s > 202 cino= cino={.5s cino={1s >
192 if (cond) if (cond) if (cond) 203 if (cond) if (cond) if (cond)
193 { { { 204 { { {
194 foo; foo; foo; 205 foo; foo; foo;
195 < 206 <
207 *cino-}*
196 }N Place closing braces N characters from the matching opening 208 }N Place closing braces N characters from the matching opening
197 brace. (default 0). 209 brace. (default 0).
198 210
199 cino= cino={2,}-0.5s cino=}2 > 211 cino= cino={2,}-0.5s cino=}2 >
200 if (cond) if (cond) if (cond) 212 if (cond) if (cond) if (cond)
201 { { { 213 { { {
202 foo; foo; foo; 214 foo; foo; foo;
203 } } } 215 } } }
204 < 216 <
217 *cino-^*
205 ^N Add N to the prevailing indent inside a set of braces if the 218 ^N Add N to the prevailing indent inside a set of braces if the
206 opening brace is in column 0. This can specify a different 219 opening brace is in column 0. This can specify a different
207 indent for whole of a function (some may like to set it to a 220 indent for whole of a function (some may like to set it to a
208 negative number). (default 0). 221 negative number). (default 0).
209 222
214 { { { 227 { { {
215 a = b; a = b; a = b; 228 a = b; a = b; a = b;
216 } } } 229 } } }
217 } } } 230 } } }
218 < 231 <
232 *cino-L*
219 LN Controls placement of jump labels. If N is negative, the label 233 LN Controls placement of jump labels. If N is negative, the label
220 will be placed at column 1. If N is non-negative, the indent of 234 will be placed at column 1. If N is non-negative, the indent of
221 the label will be the prevailing indent minus N. (default -1). 235 the label will be the prevailing indent minus N. (default -1).
222 236
223 cino= cino=L2 cino=Ls > 237 cino= cino=L2 cino=Ls >
227 stmt; stmt; stmt; 241 stmt; stmt; stmt;
228 LABEL: LABEL: LABEL: 242 LABEL: LABEL: LABEL:
229 } } } 243 } } }
230 } } } 244 } } }
231 < 245 <
246 *cino-:*
232 :N Place case labels N characters from the indent of the switch(). 247 :N Place case labels N characters from the indent of the switch().
233 (default 'shiftwidth'). 248 (default 'shiftwidth').
234 249
235 cino= cino=:0 > 250 cino= cino=:0 >
236 switch (x) switch(x) 251 switch (x) switch(x)
238 case 1: case 1: 253 case 1: case 1:
239 a = b; a = b; 254 a = b; a = b;
240 default: default: 255 default: default:
241 } } 256 } }
242 < 257 <
258 *cino-=*
243 =N Place statements occurring after a case label N characters from 259 =N Place statements occurring after a case label N characters from
244 the indent of the label. (default 'shiftwidth'). 260 the indent of the label. (default 'shiftwidth').
245 261
246 cino= cino==10 > 262 cino= cino==10 >
247 case 11: case 11: a = a + 1; 263 case 11: case 11: a = a + 1;
248 a = a + 1; b = b + 1; 264 a = a + 1; b = b + 1;
249 < 265 <
266 *cino-l*
250 lN If N != 0 Vim will align with a case label instead of the 267 lN If N != 0 Vim will align with a case label instead of the
251 statement after it in the same line. 268 statement after it in the same line.
252 269
253 cino= cino=l1 > 270 cino= cino=l1 >
254 switch (a) { switch (a) { 271 switch (a) { switch (a) {
255 case 1: { case 1: { 272 case 1: { case 1: {
256 break; break; 273 break; break;
257 } } 274 } }
258 < 275 <
276 *cino-b*
259 bN If N != 0 Vim will align a final "break" with the case label, 277 bN If N != 0 Vim will align a final "break" with the case label,
260 so that case..break looks like a sort of block. (default: 0). 278 so that case..break looks like a sort of block. (default: 0).
261 When using 1, consider adding "0=break" to 'cinkeys'. 279 When using 1, consider adding "0=break" to 'cinkeys'.
262 280
263 cino= cino=b1 > 281 cino= cino=b1 >
270 default: default: 288 default: default:
271 a = 0; a = 0; 289 a = 0; a = 0;
272 break; break; 290 break; break;
273 } } 291 } }
274 < 292 <
293 *cino-g*
275 gN Place C++ scope declarations N characters from the indent of the 294 gN Place C++ scope declarations N characters from the indent of the
276 block they are in. (default 'shiftwidth'). A scope declaration 295 block they are in. (default 'shiftwidth'). A scope declaration
277 can be "public:", "protected:" or "private:". 296 can be "public:", "protected:" or "private:".
278 297
279 cino= cino=g0 > 298 cino= cino=g0 >
281 public: public: 300 public: public:
282 a = b; a = b; 301 a = b; a = b;
283 private: private: 302 private: private:
284 } } 303 } }
285 < 304 <
305 *cino-h*
286 hN Place statements occurring after a C++ scope declaration N 306 hN Place statements occurring after a C++ scope declaration N
287 characters from the indent of the label. (default 307 characters from the indent of the label. (default
288 'shiftwidth'). 308 'shiftwidth').
289 309
290 cino= cino=h10 > 310 cino= cino=h10 >
291 public: public: a = a + 1; 311 public: public: a = a + 1;
292 a = a + 1; b = b + 1; 312 a = a + 1; b = b + 1;
293 < 313 <
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*
294 pN Parameter declarations for K&R-style function declarations will 329 pN Parameter declarations for K&R-style function declarations will
295 be indented N characters from the margin. (default 330 be indented N characters from the margin. (default
296 'shiftwidth'). 331 'shiftwidth').
297 332
298 cino= cino=p0 cino=p2s > 333 cino= cino=p0 cino=p2s >
299 func(a, b) func(a, b) func(a, b) 334 func(a, b) func(a, b) func(a, b)
300 int a; int a; int a; 335 int a; int a; int a;
301 char b; char b; char b; 336 char b; char b; char b;
302 < 337 <
338 *cino-t*
303 tN Indent a function return type declaration N characters from the 339 tN Indent a function return type declaration N characters from the
304 margin. (default 'shiftwidth'). 340 margin. (default 'shiftwidth').
305 341
306 cino= cino=t0 cino=t7 > 342 cino= cino=t0 cino=t7 >
307 int int int 343 int int int
308 func() func() func() 344 func() func() func()
309 < 345 <
346 *cino-i*
310 iN Indent C++ base class declarations and constructor 347 iN Indent C++ base class declarations and constructor
311 initializations, if they start in a new line (otherwise they 348 initializations, if they start in a new line (otherwise they
312 are aligned at the right side of the ':'). 349 are aligned at the right side of the ':').
313 (default 'shiftwidth'). 350 (default 'shiftwidth').
314 351
318 {} {} 355 {} {}
319 MyClass::MyClass() : MyClass::MyClass() : 356 MyClass::MyClass() : MyClass::MyClass() :
320 BaseClass(3) BaseClass(3) 357 BaseClass(3) BaseClass(3)
321 {} {} 358 {} {}
322 < 359 <
360 *cino-+*
323 +N Indent a continuation line (a line that spills onto the next) 361 +N Indent a continuation line (a line that spills onto the next)
324 inside a function N additional characters. (default 362 inside a function N additional characters. (default
325 'shiftwidth'). 363 'shiftwidth').
326 Outside of a function, when the previous line ended in a 364 Outside of a function, when the previous line ended in a
327 backslash, the 2 * N is used. 365 backslash, the 2 * N is used.
328 366
329 cino= cino=+10 > 367 cino= cino=+10 >
330 a = b + 9 * a = b + 9 * 368 a = b + 9 * a = b + 9 *
331 c; c; 369 c; c;
332 < 370 <
371 *cino-c*
333 cN Indent comment lines after the comment opener, when there is no 372 cN Indent comment lines after the comment opener, when there is no
334 other text with which to align, N characters from the comment 373 other text with which to align, N characters from the comment
335 opener. (default 3). See also |format-comments|. 374 opener. (default 3). See also |format-comments|.
336 375
337 cino= cino=c5 > 376 cino= cino=c5 >
338 /* /* 377 /* /*
339 text. text. 378 text. text.
340 */ */ 379 */ */
341 < 380 <
381 *cino-C*
342 CN When N is non-zero, indent comment lines by the amount specified 382 CN When N is non-zero, indent comment lines by the amount specified
343 with the c flag above even if there is other text behind the 383 with the c flag above even if there is other text behind the
344 comment opener. (default 0). 384 comment opener. (default 0).
345 385
346 cino=c0 cino=c0,C1 > 386 cino=c0 cino=c0,C1 >
347 /******** /******** 387 /******** /********
348 text. text. 388 text. text.
349 ********/ ********/ 389 ********/ ********/
350 < (Example uses ":set comments& comments-=s1:/* comments^=s0:/*") 390 < (Example uses ":set comments& comments-=s1:/* comments^=s0:/*")
351 391
392 *cino-/*
352 /N Indent comment lines N characters extra. (default 0). 393 /N Indent comment lines N characters extra. (default 0).
353 cino= cino=/4 > 394 cino= cino=/4 >
354 a = b; a = b; 395 a = b; a = b;
355 /* comment */ /* comment */ 396 /* comment */ /* comment */
356 c = d; c = d; 397 c = d; c = d;
357 < 398 <
399 *cino-(*
358 (N When in unclosed parentheses, indent N characters from the line 400 (N When in unclosed parentheses, indent N characters from the line
359 with the unclosed parentheses. Add a 'shiftwidth' for every 401 with the unclosed parentheses. Add a 'shiftwidth' for every
360 unclosed parentheses. When N is 0 or the unclosed parentheses 402 unclosed parentheses. When N is 0 or the unclosed parentheses
361 is the first non-white character in its line, line up with the 403 is the first non-white character in its line, line up with the
362 next non-white character after the unclosed parentheses. 404 next non-white character after the unclosed parentheses.
368 foo; foo; 410 foo; foo;
369 if (c1 && if (c1 && 411 if (c1 && if (c1 &&
370 (c2 || c3)) (c2 || c3)) 412 (c2 || c3)) (c2 || c3))
371 { { 413 { {
372 < 414 <
415 *cino-u*
373 uN Same as (N, but for one level deeper. (default 'shiftwidth'). 416 uN Same as (N, but for one level deeper. (default 'shiftwidth').
374 417
375 cino= cino=u2 > 418 cino= cino=u2 >
376 if (c123456789 if (c123456789 419 if (c123456789 if (c123456789
377 && (c22345 && (c22345 420 && (c22345 && (c22345
378 || c3)) || c3)) 421 || c3)) || c3))
379 < 422 <
423 *cino-U*
380 UN When N is non-zero, do not ignore the indenting specified by 424 UN When N is non-zero, do not ignore the indenting specified by
381 ( or u in case that the unclosed parentheses is the first 425 ( or u in case that the unclosed parentheses is the first
382 non-white character in its line. (default 0). 426 non-white character in its line. (default 0).
383 427
384 cino= or cino=(s cino=(s,U1 > 428 cino= or cino=(s cino=(s,U1 >
386 ( ( 430 ( (
387 c2 || c2 || 431 c2 || c2 ||
388 c3 c3 432 c3 c3
389 ) && c4; ) && c4; 433 ) && c4; ) && c4;
390 < 434 <
435 *cino-2*
391 wN When in unclosed parentheses and N is non-zero and either 436 wN When in unclosed parentheses and N is non-zero and either
392 using "(0" or "u0", respectively, or using "U0" and the unclosed 437 using "(0" or "u0", respectively, or using "U0" and the unclosed
393 parentheses is the first non-white character in its line, line 438 parentheses is the first non-white character in its line, line
394 up with the character immediately after the unclosed parentheses 439 up with the character immediately after the unclosed parentheses
395 rather than the first non-white character. (default 0). 440 rather than the first non-white character. (default 0).
398 if ( c1 if ( c1 443 if ( c1 if ( c1
399 && ( c2 && ( c2 444 && ( c2 && ( c2
400 || c3)) || c3)) 445 || c3)) || c3))
401 foo; foo; 446 foo; foo;
402 < 447 <
448 *cino-W*
403 WN When in unclosed parentheses and N is non-zero and either 449 WN When in unclosed parentheses and N is non-zero and either
404 using "(0" or "u0", respectively and the unclosed parentheses is 450 using "(0" or "u0", respectively and the unclosed parentheses is
405 the last non-white character in its line and it is not the 451 the last non-white character in its line and it is not the
406 closing parentheses, indent the following line N characters 452 closing parentheses, indent the following line N characters
407 relative to the outer context (i.e. start of the line or the 453 relative to the outer context (i.e. start of the line or the
412 argument, argument, 458 argument, argument,
413 argument); argument); 459 argument); argument);
414 a_short_line(argument, a_short_line(argument, 460 a_short_line(argument, a_short_line(argument,
415 argument); argument); 461 argument); argument);
416 < 462 <
463 *cino-m*
417 mN When N is non-zero, line up a line starting with a closing 464 mN When N is non-zero, line up a line starting with a closing
418 parentheses with the first character of the line with the 465 parentheses with the first character of the line with the
419 matching opening parentheses. (default 0). 466 matching opening parentheses. (default 0).
420 467
421 cino=(s cino=(s,m1 > 468 cino=(s cino=(s,m1 >
426 if ( if ( 473 if ( if (
427 c1 && c2 c1 && c2 474 c1 && c2 c1 && c2
428 ) ) 475 ) )
429 foo; foo; 476 foo; foo;
430 < 477 <
478 *cino-M*
431 MN When N is non-zero, line up a line starting with a closing 479 MN When N is non-zero, line up a line starting with a closing
432 parentheses with the first character of the previous line. 480 parentheses with the first character of the previous line.
433 (default 0). 481 (default 0).
434 482
435 cino= cino=M1 > 483 cino= cino=M1 >
436 if (cond1 && if (cond1 && 484 if (cond1 && if (cond1 &&
437 cond2 cond2 485 cond2 cond2
438 ) ) 486 ) )
439 < 487 <
440 *java-cinoptions* *java-indenting* 488 *java-cinoptions* *java-indenting* *cino-j*
441 jN Indent java anonymous classes correctly. The value 'N' is 489 jN Indent java anonymous classes correctly. The value 'N' is
442 currently unused but must be non-zero (e.g. 'j1'). 'j1' will 490 currently unused but must be non-zero (e.g. 'j1'). 'j1' will
443 indent for example the following code snippet correctly: > 491 indent for example the following code snippet correctly: >
444 492
445 object.add(new ChangeListener() { 493 object.add(new ChangeListener() {
446 public void stateChanged(ChangeEvent e) { 494 public void stateChanged(ChangeEvent e) {
447 do_something(); 495 do_something();
448 } 496 }
449 }); 497 });
450 < 498 <
451 *javascript-cinoptions* *javascript-indenting* 499 *javascript-cinoptions* *javascript-indenting* *cino-J*
452 JN Indent JavaScript object declarations correctly by not confusing 500 JN Indent JavaScript object declarations correctly by not confusing
453 them with labels. The value 'N' is currently unused but must be 501 them with labels. The value 'N' is currently unused but must be
454 non-zero (e.g. 'J1'). > 502 non-zero (e.g. 'J1'). >
455 503
456 var bar = { 504 var bar = {
464 x: 4, 512 x: 4,
465 "y": 5 513 "y": 5
466 } 514 }
467 } 515 }
468 < 516 <
517 *cino-)*
469 )N Vim searches for unclosed parentheses at most N lines away. 518 )N Vim searches for unclosed parentheses at most N lines away.
470 This limits the time needed to search for parentheses. (default 519 This limits the time needed to search for parentheses. (default
471 20 lines). 520 20 lines).
472 521
522 *cino-star*
473 *N Vim searches for unclosed comments at most N lines away. This 523 *N Vim searches for unclosed comments at most N lines away. This
474 limits the time needed to search for the start of a comment. 524 limits the time needed to search for the start of a comment.
475 If your /* */ comments stop indenting afer N lines this is the 525 If your /* */ comments stop indenting afer N lines this is the
476 value you will want to change. 526 value you will want to change.
477 (default 70 lines). 527 (default 70 lines).
478 528
529 *cino-#*
479 #N When N is non-zero recognize shell/Perl comments, starting with 530 #N When N is non-zero recognize shell/Perl comments, starting with
480 '#'. Default N is zero: don't recognizes '#' comments. Note 531 '#'. Default N is zero: don't recognizes '#' comments. Note
481 that lines starting with # will still be seen as preprocessor 532 that lines starting with # will still be seen as preprocessor
482 lines. 533 lines.
483 534
484 535
485 The defaults, spelled out in full, are: 536 The defaults, spelled out in full, are:
486 cinoptions=>s,e0,n0,f0,{0,}0,^0,L-1,:s,=s,l0,b0,gs,hs,ps,ts,is,+s, 537 cinoptions=>s,e0,n0,f0,{0,}0,^0,L-1,:s,=s,l0,b0,gs,hs,N0,ps,ts,is,+s,
487 c3,C0,/0,(2s,us,U0,w0,W0,m0,j0,J0,)20,*70,#0 538 c3,C0,/0,(2s,us,U0,w0,W0,m0,j0,J0,)20,*70,#0
488 539
489 Vim puts a line in column 1 if: 540 Vim puts a line in column 1 if:
490 - It starts with '#' (preprocessor directives), if 'cinkeys' contains '#'. 541 - It starts with '#' (preprocessor directives), if 'cinkeys' contains '#'.
491 - It starts with a label (a keyword followed by ':', other than "case" and 542 - It starts with a label (a keyword followed by ':', other than "case" and