blob: 72cb75f1bb65d31dc5f176a91ec646a848b438e7 [file] [log] [blame]
Bram Moolenaar9e54a0e2006-04-14 20:42:25 +00001/* start of AUTO matically checked vim: set ts=4 : */
Bram Moolenaar071d4272004-06-13 20:20:40 +00002{
3 if (test)
4 cmd1;
5 cmd2;
6}
7
8{
9 if (test)
10 cmd1;
11 else
12 cmd2;
13}
14
15{
16 if (test)
17 {
18 cmd1;
19 cmd2;
20 }
21}
22
23{
24 if (test)
25 {
26 cmd1;
27 else
28 }
29}
30
31{
32 while (this)
33 if (test)
34 cmd1;
35 cmd2;
36}
37
38{
39 while (this)
40 if (test)
41 cmd1;
42 else
43 cmd2;
44}
45
46{
47 if (test)
48 {
49 cmd;
50 }
51
52 if (test)
53 cmd;
54}
55
56{
57 if (test) {
58 cmd;
59 }
60
61 if (test) cmd;
62}
63
64{
65 cmd1;
66 for (blah)
67 while (this)
68 if (test)
69 cmd2;
70 cmd3;
71}
72
73{
74 cmd1;
75 for (blah)
76 while (this)
77 if (test)
78 cmd2;
79 cmd3;
80
81 if (test)
82 {
83 cmd1;
84 cmd2;
85 cmd3;
86 }
87}
88
89
90/* Test for 'cindent' do/while mixed with if/else: */
91
92{
93 do
94 if (asdf)
95 asdfasd;
96 while (cond);
97
98 do
99 if (asdf)
100 while (asdf)
101 asdf;
102 while (asdf);
103}
104
105/* Test for 'cindent' with two ) on a continuation line */
106{
107 if (asdfasdf;asldkfj asdlkfj as;ldkfj sal;d
108 aal;sdkjf ( ;asldfkja;sldfk
109 al;sdjfka ;slkdf ) sa;ldkjfsa dlk;)
110 line up here;
111}
112
113
114/* C++ tests: */
115
116// foo() these three lines should remain in column 0
117// {
118// }
119
120/* Test for continuation and unterminated lines: */
121{
122 i = 99 + 14325 +
123 21345 +
124 21345 +
125 21345 + ( 21345 +
126 21345) +
127 2345 +
128 1234;
129 c = 1;
130}
131
132/*
133 testje for indent with empty line
134
135 here */
136
137{
138 if (testing &&
139 not a joke ||
140 line up here)
141 hay;
142 if (testing &&
143 (not a joke || testing
144 )line up here)
145 hay;
146 if (testing &&
147 (not a joke || testing
148 line up here))
149 hay;
150}
151
152
153{
154 switch (c)
155 {
156 case xx:
157 do
158 if (asdf)
159 do
160 asdfasdf;
161 while (asdf);
162 else
163 asdfasdf;
164 while (cond);
165 case yy:
166 case xx:
167 case zz:
168 testing;
169 }
170}
171
172{
173 if (cond) {
174 foo;
175 }
176 else
177 {
178 bar;
179 }
180}
181
182{
183 if (alskdfj ;alsdkfjal;skdjf (;sadlkfsa ;dlkf j;alksdfj ;alskdjf
184 alsdkfj (asldk;fj
185 awith cino=(0 ;lf this one goes to below the paren with ==
186 ;laksjfd ;lsakdjf ;alskdf asd)
187 asdfasdf;)))
188 asdfasdf;
189}
190
191 int
192func(a, b)
193 int a;
194 int c;
195{
196 if (c1 && (c2 ||
197 c3))
198 foo;
199 if (c1 &&
200 (c2 || c3)
201 )
202}
203
204{
205 while (asd)
206 {
207 if (asdf)
208 if (test)
209 if (that)
210 {
211 if (asdf)
212 do
213 cdasd;
214 while (as
215 df);
216 }
217 else
218 if (asdf)
219 asdf;
220 else
221 asdf;
222 asdf;
223 }
224}
225
226{
227 s = "/*"; b = ';'
228 s = "/*"; b = ';';
229 a = b;
230}
231
232{
233 switch (a)
234 {
235 case a:
236 switch (t)
237 {
238 case 1:
239 cmd;
240 break;
241 case 2:
242 cmd;
243 break;
244 }
245 cmd;
246 break;
247 case b:
248 {
249 int i;
250 cmd;
251 }
252 break;
253 case c: {
254 int i;
255 cmd;
256 }
257 case d: if (cond &&
258 test) { /* this line doesn't work right */
259 int i;
260 cmd;
261 }
262 break;
263 }
264}
265
266{
267 if (!(vim_strchr(p_cpo, CPO_BUFOPTGLOB) != NULL && entering) &&
268 (bp_to->b_p_initialized ||
269 (!entering && vim_strchr(p_cpo, CPO_BUFOPT) != NULL)))
270 return;
271label :
272 asdf = asdf ?
273 asdf : asdf;
274 asdf = asdf ?
275 asdf: asdf;
276}
277
278/* Special Comments : This function has the added complexity (compared */
279/* : to addtolist) of having to check for a detail */
280/* : texture and add that to the list first. */
281
282char *(array[100]) = {
283 "testje",
284 "foo",
285 "bar",
286}
287
288enum soppie
289{
290 yes = 0,
291 no,
292 maybe
293};
294
295typedef enum soppie
296{
297 yes = 0,
298 no,
299 maybe
300};
301
Bram Moolenaara5285652011-12-14 20:05:21 +0100302static enum
303{
304 yes = 0,
305 no,
306 maybe
307} soppie;
308
Bram Moolenaar071d4272004-06-13 20:20:40 +0000309{
310 int a,
311 b;
312}
313
314{
315 struct Type
316 {
317 int i;
318 char *str;
319 } var[] =
320 {
321 0, "zero",
322 1, "one",
323 2, "two",
324 3, "three"
325 };
326
327 float matrix[3][3] =
328 {
329 {
330 0,
331 1,
332 2
333 },
334 {
335 3,
336 4,
337 5
338 },
339 {
340 6,
341 7,
342 8
343 }
344 };
345}
346
347{
348 /* blah ( blah */
349 /* where does this go? */
350
351 /* blah ( blah */
352 cmd;
353
354 func(arg1,
355 /* comment */
356 arg2);
357 a;
358 {
359 b;
360 {
361 c; /* Hey, NOW it indents?! */
362 }
363 }
364
365 {
366 func(arg1,
367 arg2,
368 arg3);
369 /* Hey, what am I doing here? Is this coz of the ","? */
370 }
371}
372
373main ()
374{
375 if (cond)
376 {
377 a = b;
378 }
379 if (cond) {
380 a = c;
381 }
382 if (cond)
383 a = d;
384 return;
385}
386
387{
388 case 2: if (asdf &&
389 asdfasdf)
390 aasdf;
391 a = 9;
392 case 3: if (asdf)
393 aasdf;
394 a = 9;
395 case 4: x = 1;
396 y = 2;
397
398label: if (asdf)
399 here;
400
401label: if (asdf &&
402 asdfasdf)
403 {
404 }
405
406label: if (asdf &&
407 asdfasdf) {
408 there;
409 }
410
411label: if (asdf &&
412 asdfasdf)
413 there;
414}
415
416{
417 /*
418 hello with ":set comments= cino=c5"
419 */
420
421 /*
422 hello with ":set comments= cino="
423 */
424}
425
426
427{
428 if (a < b) {
429 a = a + 1;
430 } else
431 a = a + 2;
432
433 if (a)
434 do {
435 testing;
436 } while (asdfasdf);
437 a = b + 1;
438 asdfasdf
439}
440
441class bob
442{
443 int foo() {return 1;}
444 int bar;
445}
446
447main()
448{
449 while(1)
450 if (foo)
451 {
452 bar;
453 }
454 else {
455 asdf;
456 }
457 misplacedline;
458}
459
460{
461 if (clipboard.state == SELECT_DONE
462 && ((row == clipboard.start.lnum
463 && col >= clipboard.start.col)
464 || row > clipboard.start.lnum))
465}
466
467{
468 if (1) {i += 4;}
469 where_am_i;
470 return 0;
471}
472
473{
474 {
475 } // sdf(asdf
476 if (asdf)
477 asd;
478}
479
480{
481label1:
482label2:
483}
484
485{
486 int fooRet = foo(pBar1, false /*fKB*/,
487 true /*fPTB*/, 3 /*nT*/, false /*fDF*/);
488 f() {
489 for ( i = 0;
490 i < m;
491 /* c */ i++ ) {
492 a = b;
493 }
494 }
495}
496
497{
498 f1(/*comment*/);
499 f2();
500}
501
502{
503 do {
504 if (foo) {
505 } else
506 ;
507 } while (foo);
508 foo(); // was wrong
509}
510
511int x; // no extra indent because of the ;
512void func()
513{
514}
515
516char *tab[] = {"aaa",
517 "};", /* }; */ NULL}
518 int indented;
519{}
520
521char *a[] = {"aaa", "bbb",
522 "ccc", NULL};
523// here
524
525char *tab[] = {"aaa",
526 "xx", /* xx */}; /* asdf */
527int not_indented;
528
529{
530 do {
531 switch (bla)
532 {
533 case 1: if (foo)
534 bar;
535 }
536 } while (boo);
537 wrong;
538}
539
540int foo,
541 bar;
542int foo;
543
544#if defined(foo) \
545 && defined(bar)
546char * xx = "asdf\
547 foo\
548 bor";
549int x;
550
551char *foo = "asdf\
552 asdf\
553 asdf",
554 *bar;
555
556void f()
557{
558#if defined(foo) \
559 && defined(bar)
560 char *foo = "asdf\
561 asdf\
562 asdf",
563 *bar;
564 {
565 int i;
566 char *foo = "asdf\
567 asdf\
568 asdf",
569 *bar;
570 }
571#endif
572}
573#endif
574
575int y; // comment
576// comment
577
578// comment
579
580{
581 Constructor(int a,
582 int b ) : BaseClass(a)
583 {
584 }
585}
586
587void foo()
588{
589 char one,
590 two;
591 struct bla piet,
592 jan;
593 enum foo kees,
594 jannie;
595 static unsigned sdf,
596 krap;
597 unsigned int piet,
598 jan;
599 int
600 kees,
601 jan;
602}
603
604{
605 t(int f,
606 int d); // )
607 d();
608}
609
610Constructor::Constructor(int a,
611 int b
612 ) :
613 BaseClass(a,
614 b,
615 c),
616 mMember(b),
617{
618}
619
620Constructor::Constructor(int a,
621 int b ) :
622 BaseClass(a)
623{
624}
625
626Constructor::Constructor(int a,
627 int b ) /*x*/ : /*x*/ BaseClass(a),
Bram Moolenaar7fc904b2006-04-13 20:37:35 +0000628 member(b)
Bram Moolenaar071d4272004-06-13 20:20:40 +0000629{
630}
631
632class CAbc :
633 public BaseClass1,
634 protected BaseClass2
635{
636 int Test() { return FALSE; }
637 int Test1() { return TRUE; }
638
639 CAbc(int a, int b ) :
640 BaseClass(a)
641 {
642 switch(xxx)
643 {
644 case abc:
645 asdf();
646 break;
647
648 case 999:
649 baer();
650 break;
651 }
652 }
653
654 public: // <-- this was incoreectly indented before!!
655 void testfall();
656 protected:
657 void testfall();
658};
659
660class CAbc : public BaseClass1,
Bram Moolenaar7fc904b2006-04-13 20:37:35 +0000661 protected BaseClass2
Bram Moolenaar071d4272004-06-13 20:20:40 +0000662{
663};
664
665static struct
666{
667 int a;
668 int b;
669} variable[COUNT] =
670{
671 {
672 123,
673 456
674 },
675 {
676 123,
677 456
678 }
679};
680
681static struct
682{
683 int a;
684 int b;
685} variable[COUNT] =
686{
687 { 123, 456 },
688 { 123, 456 }
689};
690
691void asdf() /* ind_maxparen may cause trouble here */
692{
693 if ((0
694 && 1
695 && 1
696 && 1
697 && 1
698 && 1
699 && 1
700 && 1
701 && 1
702 && 1
703 && 1
704 && 1
705 && 1
706 && 1
707 && 1
708 && 1
709 && 1
710 && 1
711 && 1
712 && 1
713 && 1
714 && 1
715 && 1
716 && 1
717 && 1
718 && 1)) break;
719}
720
Bram Moolenaar18144c82006-04-12 21:52:12 +0000721foo()
722{
723 a = cond ? foo() : asdf
724 + asdf;
725
726 a = cond ?
727 foo() : asdf
728 + asdf;
729}
730
731int main(void)
732{
733 if (a)
734 if (b)
735 2;
736 else 3;
737 next_line_of_code();
738}
739
Bram Moolenaar7fc904b2006-04-13 20:37:35 +0000740barry()
741{
742 Foo::Foo (int one,
743 int two)
744 : something(4)
745 {}
746}
747
748barry()
749{
750 Foo::Foo (int one, int two)
751 : something(4)
752 {}
753}
754
755Constructor::Constructor(int a,
756 int b
757 ) :
758 BaseClass(a,
759 b,
760 c),
761 mMember(b)
762{
763}
Bram Moolenaar9e54a0e2006-04-14 20:42:25 +0000764int main ()
765{
766 if (lala)
767 do
768 ++(*lolo);
769 while (lili
770 && lele);
771 lulu;
772}
Bram Moolenaar7fc904b2006-04-13 20:37:35 +0000773
Bram Moolenaar9e54a0e2006-04-14 20:42:25 +0000774int main ()
775{
776 switch (c)
777 {
778 case 'c': if (cond)
779 {
780 }
781 }
782}
783
784main()
785{
786 (void) MyFancyFuasdfadsfnction(
787 argument);
788}
789
790main()
791{
792 char foo[] = "/*";
793 /* as
794 df */
795 hello
796}
Bram Moolenaared38b0a2011-05-25 15:16:18 +0200797
798/* valid namespaces with normal indent */
799namespace
800{
801 {
802 111111111111;
803 }
804}
805namespace /* test */
806{
807 11111111111111111;
808}
809namespace // test
810{
811 111111111111111111;
812}
813namespace
814{
815 111111111111111111;
816}
817namespace test
818{
819 111111111111111111;
820}
821namespace{
822 111111111111111111;
823}
824namespace test{
825 111111111111111111;
826}
827namespace {
828 111111111111111111;
829}
830namespace test {
831 111111111111111111;
832 namespace test2 {
833 22222222222222222;
834 }
835}
836
837/* invalid namespaces use block indent */
838namespace test test2 {
839 111111111111111111111;
840}
841namespace11111111111 {
842 111111111111;
843}
844namespace() {
845 1111111111111;
846}
847namespace()
848{
849 111111111111111111;
850}
851namespace test test2
852{
853 1111111111111111111;
854}
855namespace111111111
856{
857 111111111111111111;
858}
859
Bram Moolenaar071d4272004-06-13 20:20:40 +0000860/* end of AUTO */
861
862
863{
864
865/* this is
866 * a real serious
867 * about life, the
868 * universe, and the
869 * rest important big
870 * comment
871 */
872 /* insert " about life, the universe, and the rest" after "serious" */
873}
874
875
876{
877 /*
878 * Testing for comments, without 'cin' set
879 */
880about life
881
882/*
883* what happens here?
884*/
885there
886
887 /*
888 the end of the comment, try inserting a line below */
889line
890
891 /* how about
892hello
893 this one */
894}
895
896
897{
898 var = this + that + vec[0] * vec[0]
899 + vec[1] * vec[1]
900 + vec2[2] * vec[2];
901}
902
903
904{
905 asdf asdflkajds f;
906 if (tes & ting) {
907 asdf asdf asdf ;
908 asdfa sdf asdf;
909 }
910 testing1;
911 if (tes & ting)
912 {
913 asdf asdf asdf ;
914 asdfa sdf asdf;
915 }
916 testing2;
917}
918
919
920main ( int first_par, /*
921 * Comment for
922 * first par
923 */
924 int second_par /*
925 * Comment for
926 * second par
927 */
928 )
929{
930 func( first_par, /*
931 * Comment for
932 * first par
933 */
934 second_par /*
935 * Comment for
936 * second par
937 */
938 );
939
940}
941
942
943{
944 do
945 {
946 if ()
947 {
948 if ()
949 asdf;
950 else
951 asdf;
952 }
953 } while ();
954 cmd; /* this should go under the } */
955}
956
957
958void f()
959{
960 if ( k() ) {
961 l();
962
963 } else { /* Start (two words) end */
964 m();
965 }
966
967 n();
968}
969
970
971void f()
972 {
973 if ( k() )
974 {
975 l();
976 } else { /* Start (two words) end */
977 m();
978 }
979 n(); /* should be under the if () */
980}
981
982
983void bar(void)
984 {
985 static array[2][2] =
986 {
987 { 1, 2 },
988 { 3, 4 },
989 }
990
991 while (a)
992 {
993 foo(&a);
994 }
995
996 {
997 int a;
998 {
999 a = a + 1;
1000 }
1001 }
1002 b = a;
1003 }
1004
1005void func(void)
1006 {
1007 a = 1;
1008 {
1009 b = 2;
1010 }
1011 c = 3;
1012 d = 4;
1013 }
1014/* foo */
1015
1016
1017a()
1018{
1019 do {
1020 a = a +
1021 a;
1022 } while ( a ); /* add text under this line */
1023 here
1024 if ( a )
1025 a;
1026}
1027
1028
1029a()
1030{
1031label1:
1032 /* hmm */
1033 // comment
1034label2: b();
1035label3 /* post */:
1036/* pre */ label4:
1037 f(/*com*/);
1038 if (/*com*/)
1039 cmd();
1040}
1041
1042
1043/*
1044 * A simple comment
1045 */
1046
1047/*
1048** A different comment
1049*/
1050
1051
1052void f()
1053{
1054
1055 /*********
1056 A comment.
1057 *********/
1058}
1059
1060
1061void f()
1062{
1063
1064 /*********
1065 A comment.
1066 *********/
1067}
1068
1069
1070void f()
1071{
1072 c = c1 &&
1073 (
1074 c2 ||
1075 c3
1076 ) && c4;
1077}
1078
1079
1080void f()
1081{
1082 c = c1 &&
1083 (
1084 c2 ||
1085 c3
1086 ) && c4;
1087}
1088
1089
1090void f()
1091{
1092 c = c1 &&
1093 (
1094 c2 ||
1095 c3
1096 ) && c4;
1097}
1098
1099
1100void f()
1101{
1102 if ( c1
1103 && ( c2
1104 || c3))
1105 foo;
1106}
1107
1108
1109void f()
1110{
1111 if ( c1
1112 && ( c2
1113 || c3))
1114 foo;
1115}
1116
1117
1118void f()
1119{
1120 c = c1 && (
1121 c2 ||
1122 c3
1123 ) && c4;
1124 if (
1125 c1 && c2
1126 )
1127 foo;
1128}
1129
1130
1131void f()
1132{
1133 c = c1 && (
1134 c2 ||
1135 c3
1136 ) && c4;
1137 if (
1138 c1 && c2
1139 )
1140 foo;
1141}
1142
1143
1144void f()
1145{
1146 switch (x)
1147 {
1148 case 1:
1149 a = b;
1150 break;
1151 default:
1152 a = 0;
1153 break;
1154 }
1155}
1156
1157
1158void f()
1159{
1160 invokeme(
1161 argu,
1162 ment);
1163 invokeme(
1164 argu,
1165 ment
1166 );
1167 invokeme(argu,
1168 ment
1169 );
1170}
1171
1172
1173void f()
1174{
1175 statement;
1176 // comment 1
1177 // comment 2
1178}
1179
1180
1181void f()
1182{
1183 statement;
1184 // comment 1
1185 // comment 2
1186}
1187
1188
1189class CAbc
1190{
1191 int Test() { return FALSE; }
1192
1193public: // comment
1194 void testfall();
1195protected:
1196 void testfall();
1197};
1198
1199
Bram Moolenaare79d1532011-10-04 18:03:47 +02001200class Foo : public Bar
1201{
1202 public:
1203 virtual void method1(void) = 0;
1204 virtual void method2(int arg1,
1205 int arg2,
1206 int arg3) = 0;
1207};
1208
1209
Bram Moolenaar7fc904b2006-04-13 20:37:35 +00001210 void
1211foo()
1212{
1213 if (a)
1214 {
1215 } else
1216 asdf;
1217}
1218
1219
Bram Moolenaar071d4272004-06-13 20:20:40 +00001220{
1221 averylongfunctionnamelongfunctionnameaverylongfunctionname()->asd(
1222 asdasdf,
1223 func(asdf,
1224 asdfadsf),
1225 asdfasdf
1226 );
1227
1228 /* those are ugly, but consequent */
1229
1230 func()->asd(asdasdf,
1231 averylongfunctionname(
1232 abc,
1233 dec)->averylongfunctionname(
1234 asdfadsf,
1235 asdfasdf,
1236 asdfasdf,
1237 ),
1238 func(asdfadf,
1239 asdfasdf
1240 ),
1241 asdasdf
1242 );
1243
1244 averylongfunctionnameaverylongfunctionnameavery()->asd(fasdf(
1245 abc,
1246 dec)->asdfasdfasdf(
1247 asdfadsf,
1248 asdfasdf,
1249 asdfasdf,
1250 ),
1251 func(asdfadf,
1252 asdfasdf),
1253 asdasdf
1254 );
1255}
1256
Bram Moolenaar9e54a0e2006-04-14 20:42:25 +00001257
1258int main ()
1259{
1260 if (cond1 &&
1261 cond2
1262 )
1263 foo;
1264}
1265
Bram Moolenaar8d2d71d2011-04-28 13:02:09 +02001266
1267void func(int a
1268#if defined(FOO)
1269 , int b
1270 , int c
1271#endif
1272 )
1273{
1274}
1275
1276
1277 void
1278func(int a
1279#if defined(FOO)
1280 , int b
1281 , int c
1282#endif
1283 )
1284{
1285}
1286
Bram Moolenaar4ae06c12011-05-10 11:39:19 +02001287
1288void func(void)
1289{
1290 if(x==y)
1291 if(y==z)
1292 foo=1;
1293 else { bar=1;
1294 baz=2;
1295 }
1296 printf("Foo!\n");
1297}
1298
Bram Moolenaar496f9512011-05-19 16:35:09 +02001299void func1(void)
1300{
1301 char* tab[] = {"foo", "bar",
1302 "baz", "quux",
1303 "this line used", "to be indented incorrectly"};
1304 foo();
1305}
1306
1307void func2(void)
1308{
1309 int tab[] =
1310 {1, 2,
1311 3, 4,
1312 5, 6};
1313
1314 printf("This line used to be indented incorrectly.\n");
1315}
1316
Bram Moolenaar3388bb42011-11-30 17:20:23 +01001317int foo[]
1318#ifdef BAR
1319
1320= { 1, 2, 3,
1321 4, 5, 6 }
1322
1323#endif
1324 ;
1325int baz;
1326
Bram Moolenaar496f9512011-05-19 16:35:09 +02001327void func3(void)
1328{
1329 int tab[] = {
1330 1, 2,
1331 3, 4,
1332 5, 6};
1333
Bram Moolenaarc367faa2011-12-14 20:21:35 +01001334 printf("Don't you dare indent this line incorrectly!\n");
1335}
1336
1337 void
1338func4(a, b,
1339 c)
1340 int a;
1341 int b;
1342 int c;
1343{
1344}
1345
1346 void
1347func5(
1348 int a,
1349 int b)
1350{
1351}
1352
1353 void
1354func6(
1355 int a)
1356{
Bram Moolenaar496f9512011-05-19 16:35:09 +02001357}
1358
Bram Moolenaaraede6ce2011-05-10 11:56:30 +02001359
1360void func(void)
1361{
Bram Moolenaar50f42ca2011-07-15 14:12:30 +02001362 int tab[] =
1363 {
1364 1, 2, 3,
1365 4, 5, 6};
1366
1367 printf("Indent this line correctly!\n");
1368
1369 switch (foo)
1370 {
1371 case bar:
1372 printf("bar");
1373 break;
1374 case baz: {
1375 printf("baz");
1376 break;
1377 }
1378 case quux:
1379 printf("But don't break the indentation of this instruction\n");
1380 break;
1381 }
1382}
1383
1384
1385void func(void)
1386{
Bram Moolenaaraede6ce2011-05-10 11:56:30 +02001387 cout << "a"
1388 << "b"
1389 << ") :"
1390 << "c";
1391}
1392
Bram Moolenaara4271d52011-05-10 13:38:27 +02001393
1394void func(void)
1395{
1396 /*
1397 * This is a comment.
1398 */
1399 foo();
1400}
1401
Bram Moolenaar334adf02011-05-25 13:34:04 +02001402
1403void func(void)
1404{
1405 for (int i = 0; i < 10; ++i)
1406 if (i & 1) {
1407 foo(1);
1408 } else
1409 foo(0);
1410 baz();
1411}
1412
Bram Moolenaared38b0a2011-05-25 15:16:18 +02001413
Bram Moolenaar3675fa02012-04-05 17:17:42 +02001414void func(void)
1415{
1416 if (condition1
1417 && condition2)
1418 action();
1419 function(argument1
1420 && argument2);
1421
1422 if (c1 && (c2 ||
1423 c3))
1424 foo;
1425 if (c1 &&
1426 (c2 || c3))
1427 {
1428 }
1429
1430 if ( c1
1431 && ( c2
1432 || c3))
1433 foo;
1434 func( c1
1435 && ( c2
1436 || c3))
1437 foo;
1438}
1439
1440
1441void func(void)
1442{
1443 if (condition1
1444 && condition2)
1445 action();
1446 function(argument1
1447 && argument2);
1448
1449 if (c1 && (c2 ||
1450 c3))
1451 foo;
1452 if (c1 &&
1453 (c2 || c3))
1454 {
1455 }
1456
1457 if ( c1
1458 && ( c2
1459 || c3))
1460 foo;
1461 func( c1
1462 && ( c2
1463 || c3))
1464 foo;
1465}
1466
1467
1468void func(void)
1469{
1470 if (condition1
1471 && condition2)
1472 action();
1473 function(argument1
1474 && argument2);
1475
1476 if (c1 && (c2 ||
1477 c3))
1478 foo;
1479 if (c1 &&
1480 (c2 || c3))
1481 {
1482 }
1483 if (c123456789
1484 && (c22345
1485 || c3))
1486 printf("foo\n");
1487
1488 c = c1 &&
1489 (
1490 c2 ||
1491 c3
1492 ) && c4;
1493}
1494
1495
1496void func(void)
1497{
1498 if (condition1
1499 && condition2)
1500 action();
1501 function(argument1
1502 && argument2);
1503
1504 if (c1 && (c2 ||
1505 c3))
1506 foo;
1507 if (c1 &&
1508 (c2 || c3))
1509 {
1510 }
1511 if (c123456789
1512 && (c22345
1513 || c3))
1514 printf("foo\n");
1515
1516 if ( c1
1517 && ( c2
1518 || c3))
1519 foo;
1520
1521 a_long_line(
1522 argument,
1523 argument);
1524 a_short_line(argument,
1525 argument);
1526}
1527
1528
1529void func(void)
1530{
1531 if (condition1
1532 && condition2)
1533 action();
1534 function(argument1
1535 && argument2);
1536
1537 if (c1 && (c2 ||
1538 c3))
1539 foo;
1540 if (c1 &&
1541 (c2 || c3))
1542 {
1543 }
1544 if (c123456789
1545 && (c22345
1546 || c3))
1547 printf("foo\n");
1548}
1549
1550
1551void func(void)
1552{
1553 if (condition1
1554 && condition2)
1555 action();
1556 function(argument1
1557 && argument2);
1558
1559 if (c1 && (c2 ||
1560 c3))
1561 foo;
1562 if (c1 &&
1563 (c2 || c3))
1564 {
1565 }
1566 if (c123456789
1567 && (c22345
1568 || c3))
1569 printf("foo\n");
1570
1571 if ( c1
1572 && ( c2
1573 || c3))
1574 foo;
1575 func( c1
1576 && ( c2
1577 || c3))
1578 foo;
1579}
1580
1581
1582void func(void)
1583{
1584 if (condition1
1585 && condition2)
1586 action();
1587 function(argument1
1588 && argument2);
1589
1590 if (c1 && (c2 ||
1591 c3))
1592 foo;
1593 if (c1 &&
1594 (c2 || c3))
1595 {
1596 }
1597}
1598
1599
Bram Moolenaar6ec154b2011-06-12 21:51:08 +02001600NAMESPACESTART
Bram Moolenaared38b0a2011-05-25 15:16:18 +02001601/* valid namespaces with normal indent */
1602namespace
1603{
1604{
1605 111111111111;
1606}
1607}
1608namespace /* test */
1609{
161011111111111111111;
1611}
1612namespace // test
1613{
1614111111111111111111;
1615}
1616namespace
1617{
1618111111111111111111;
1619}
1620namespace test
1621{
1622111111111111111111;
1623}
1624namespace{
1625111111111111111111;
1626}
1627namespace test{
1628111111111111111111;
1629}
1630namespace {
1631111111111111111111;
1632}
1633namespace test {
1634111111111111111111;
1635namespace test2 {
163622222222222222222;
1637}
1638}
1639
1640/* invalid namespaces use block indent */
1641namespace test test2 {
1642 111111111111111111111;
1643}
1644namespace11111111111 {
1645 111111111111;
1646}
1647namespace() {
1648 1111111111111;
1649}
1650namespace()
1651{
1652 111111111111111111;
1653}
1654namespace test test2
1655{
1656 1111111111111111111;
1657}
1658namespace111111111
1659{
1660 111111111111111111;
1661}
1662NAMESPACEEND
1663
1664
Bram Moolenaar6ec154b2011-06-12 21:51:08 +02001665
1666JSSTART
1667var bar = {
1668 foo: {
1669 that: this,
1670 some: ok,
1671 },
1672 "bar":{
1673 a : 2,
1674 b: "123abc",
1675 x: 4,
1676 "y": 5
1677 }
1678}
1679JSEND
1680
Bram Moolenaar76f7fd32011-07-20 15:09:43 +02001681
1682JSSTART
1683var foo = [
16841, // indent 8 more
1685 2,
1686 3
1687 ]; // indent 8 less
1688JSEND
1689
1690
1691JSSTART
1692function bar() {
1693 var foo = [
1694 1,
1695 2,
1696 3
1697 ]; // indent 16 less
1698}
1699JSEND
1700
1701
1702JSSTART
1703(function($){
1704
1705 var class_name='myclass';
1706
1707 function private_method() {
1708 }
1709
1710 var public_method={
1711 method: function(options,args){
1712 private_method();
1713 }
1714 }
1715
1716 function init(options) {
1717
1718 $(this).data(class_name+'_public',$.extend({},{
1719 foo: 'bar',
1720 bar: 2, // indent 8 more
1721 foobar: [ // indent 8 more
1722 1, // indent 8 more
1723 2, // indent 16 more
1724 3 // indent 16 more
1725 ],
1726 callback: function(){ // indent 8 more
1727 return true; // indent 8 more
1728 } // indent 8 more
1729 }, options||{}));
1730 }
1731
1732 $.fn[class_name]=function() {
1733
1734 var _arguments=arguments;
1735 return this.each(function(){
1736
1737 var options=$(this).data(class_name+'_public');
1738 if (!options) {
1739 init.apply(this,_arguments);
1740
1741 } else {
1742 var method=public_method[_arguments[0]];
1743
1744 if (typeof(method)!='function') {
1745 console.log(class_name+' has no method "'+_arguments[0]+'"');
1746 return false;
1747 }
1748 _arguments[0]=options;
1749 method.apply(this,_arguments);
1750 }
1751 });
1752 }
1753
1754})(jQuery);
1755JSEND
1756
1757
1758JSSTART
1759function init(options) {
1760 $(this).data(class_name+'_public',$.extend({},{
1761 foo: 'bar',
1762 bar: 2,
1763 foobar: [
1764 1, // indent 8 more
1765 2, // indent 8 more
1766 3 // indent 8 more
1767 ],
1768 callback: function(){
1769 return true;
1770 }
1771 }, options||{}));
1772}
1773JSEND
1774
1775
1776JSSTART
1777(function($){
1778 function init(options) {
1779 $(this).data(class_name+'_public',$.extend({},{
1780 foo: 'bar',
1781 bar: 2, // indent 8 more
1782 foobar: [ // indent 8 more
1783 1, // indent 8 more
1784 2, // indent 16 more
1785 3 // indent 16 more
1786 ],
1787 callback: function(){ // indent 8 more
1788 return true; // indent 8 more
1789 } // indent 8 more
1790 }, options||{}));
1791 }
1792})(jQuery);
1793JSEND
1794