blob: 011751be8b1e50f148641ce03d701e0645c484d5 [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
Bram Moolenaar48d27922012-06-13 13:40:48 +0200943main(void)
944{
945 /* Make sure that cino=X0s is not parsed like cino=Xs. */
946 if (cond)
947 foo();
948 else
949 {
950 bar();
951 }
952}
953
954
Bram Moolenaar071d4272004-06-13 20:20:40 +0000955{
956 do
957 {
958 if ()
959 {
960 if ()
961 asdf;
962 else
963 asdf;
964 }
965 } while ();
966 cmd; /* this should go under the } */
967}
968
969
970void f()
971{
972 if ( k() ) {
973 l();
974
975 } else { /* Start (two words) end */
976 m();
977 }
978
979 n();
980}
981
982
983void f()
984 {
985 if ( k() )
986 {
987 l();
988 } else { /* Start (two words) end */
989 m();
990 }
991 n(); /* should be under the if () */
992}
993
994
995void bar(void)
996 {
997 static array[2][2] =
998 {
999 { 1, 2 },
1000 { 3, 4 },
1001 }
1002
1003 while (a)
1004 {
1005 foo(&a);
1006 }
1007
1008 {
1009 int a;
1010 {
1011 a = a + 1;
1012 }
1013 }
1014 b = a;
1015 }
1016
1017void func(void)
1018 {
1019 a = 1;
1020 {
1021 b = 2;
1022 }
1023 c = 3;
1024 d = 4;
1025 }
1026/* foo */
1027
1028
1029a()
1030{
1031 do {
1032 a = a +
1033 a;
1034 } while ( a ); /* add text under this line */
1035 here
1036 if ( a )
1037 a;
1038}
1039
1040
1041a()
1042{
1043label1:
1044 /* hmm */
1045 // comment
1046label2: b();
1047label3 /* post */:
1048/* pre */ label4:
1049 f(/*com*/);
1050 if (/*com*/)
1051 cmd();
1052}
1053
1054
1055/*
1056 * A simple comment
1057 */
1058
1059/*
1060** A different comment
1061*/
1062
1063
1064void f()
1065{
1066
1067 /*********
1068 A comment.
1069 *********/
1070}
1071
1072
1073void f()
1074{
1075
1076 /*********
1077 A comment.
1078 *********/
1079}
1080
1081
1082void f()
1083{
1084 c = c1 &&
1085 (
1086 c2 ||
1087 c3
1088 ) && c4;
1089}
1090
1091
1092void f()
1093{
1094 c = c1 &&
1095 (
1096 c2 ||
1097 c3
1098 ) && c4;
1099}
1100
1101
1102void f()
1103{
1104 c = c1 &&
1105 (
1106 c2 ||
1107 c3
1108 ) && c4;
1109}
1110
1111
1112void f()
1113{
1114 if ( c1
1115 && ( c2
1116 || c3))
1117 foo;
1118}
1119
1120
1121void f()
1122{
1123 if ( c1
1124 && ( c2
1125 || c3))
1126 foo;
1127}
1128
1129
1130void f()
1131{
1132 c = c1 && (
1133 c2 ||
1134 c3
1135 ) && c4;
1136 if (
1137 c1 && c2
1138 )
1139 foo;
1140}
1141
1142
1143void f()
1144{
1145 c = c1 && (
1146 c2 ||
1147 c3
1148 ) && c4;
1149 if (
1150 c1 && c2
1151 )
1152 foo;
1153}
1154
1155
1156void f()
1157{
1158 switch (x)
1159 {
1160 case 1:
1161 a = b;
1162 break;
1163 default:
1164 a = 0;
1165 break;
1166 }
1167}
1168
1169
1170void f()
1171{
1172 invokeme(
1173 argu,
1174 ment);
1175 invokeme(
1176 argu,
1177 ment
1178 );
1179 invokeme(argu,
1180 ment
1181 );
1182}
1183
1184
1185void f()
1186{
1187 statement;
1188 // comment 1
1189 // comment 2
1190}
1191
1192
1193void f()
1194{
1195 statement;
1196 // comment 1
1197 // comment 2
1198}
1199
1200
1201class CAbc
1202{
1203 int Test() { return FALSE; }
1204
1205public: // comment
1206 void testfall();
1207protected:
1208 void testfall();
1209};
1210
1211
Bram Moolenaare79d1532011-10-04 18:03:47 +02001212class Foo : public Bar
1213{
1214 public:
1215 virtual void method1(void) = 0;
1216 virtual void method2(int arg1,
1217 int arg2,
1218 int arg3) = 0;
1219};
1220
1221
Bram Moolenaar7fc904b2006-04-13 20:37:35 +00001222 void
1223foo()
1224{
1225 if (a)
1226 {
1227 } else
1228 asdf;
1229}
1230
1231
Bram Moolenaar071d4272004-06-13 20:20:40 +00001232{
1233 averylongfunctionnamelongfunctionnameaverylongfunctionname()->asd(
1234 asdasdf,
1235 func(asdf,
1236 asdfadsf),
1237 asdfasdf
1238 );
1239
1240 /* those are ugly, but consequent */
1241
1242 func()->asd(asdasdf,
1243 averylongfunctionname(
1244 abc,
1245 dec)->averylongfunctionname(
1246 asdfadsf,
1247 asdfasdf,
1248 asdfasdf,
1249 ),
1250 func(asdfadf,
1251 asdfasdf
1252 ),
1253 asdasdf
1254 );
1255
1256 averylongfunctionnameaverylongfunctionnameavery()->asd(fasdf(
1257 abc,
1258 dec)->asdfasdfasdf(
1259 asdfadsf,
1260 asdfasdf,
1261 asdfasdf,
1262 ),
1263 func(asdfadf,
1264 asdfasdf),
1265 asdasdf
1266 );
1267}
1268
Bram Moolenaar9e54a0e2006-04-14 20:42:25 +00001269
1270int main ()
1271{
1272 if (cond1 &&
1273 cond2
1274 )
1275 foo;
1276}
1277
Bram Moolenaar8d2d71d2011-04-28 13:02:09 +02001278
1279void func(int a
1280#if defined(FOO)
1281 , int b
1282 , int c
1283#endif
1284 )
1285{
1286}
1287
1288
1289 void
1290func(int a
1291#if defined(FOO)
1292 , int b
1293 , int c
1294#endif
1295 )
1296{
1297}
1298
Bram Moolenaar4ae06c12011-05-10 11:39:19 +02001299
1300void func(void)
1301{
1302 if(x==y)
1303 if(y==z)
1304 foo=1;
1305 else { bar=1;
1306 baz=2;
1307 }
1308 printf("Foo!\n");
1309}
1310
Bram Moolenaar496f9512011-05-19 16:35:09 +02001311void func1(void)
1312{
1313 char* tab[] = {"foo", "bar",
1314 "baz", "quux",
1315 "this line used", "to be indented incorrectly"};
1316 foo();
1317}
1318
1319void func2(void)
1320{
1321 int tab[] =
1322 {1, 2,
1323 3, 4,
1324 5, 6};
1325
1326 printf("This line used to be indented incorrectly.\n");
1327}
1328
Bram Moolenaar3388bb42011-11-30 17:20:23 +01001329int foo[]
1330#ifdef BAR
1331
1332= { 1, 2, 3,
1333 4, 5, 6 }
1334
1335#endif
1336 ;
1337int baz;
1338
Bram Moolenaar496f9512011-05-19 16:35:09 +02001339void func3(void)
1340{
1341 int tab[] = {
1342 1, 2,
1343 3, 4,
1344 5, 6};
1345
Bram Moolenaarc367faa2011-12-14 20:21:35 +01001346 printf("Don't you dare indent this line incorrectly!\n");
1347}
1348
1349 void
1350func4(a, b,
1351 c)
1352 int a;
1353 int b;
1354 int c;
1355{
1356}
1357
1358 void
1359func5(
1360 int a,
1361 int b)
1362{
1363}
1364
1365 void
1366func6(
1367 int a)
1368{
Bram Moolenaar496f9512011-05-19 16:35:09 +02001369}
1370
Bram Moolenaaraede6ce2011-05-10 11:56:30 +02001371
1372void func(void)
1373{
Bram Moolenaar50f42ca2011-07-15 14:12:30 +02001374 int tab[] =
1375 {
1376 1, 2, 3,
1377 4, 5, 6};
1378
1379 printf("Indent this line correctly!\n");
1380
1381 switch (foo)
1382 {
1383 case bar:
1384 printf("bar");
1385 break;
1386 case baz: {
1387 printf("baz");
1388 break;
1389 }
1390 case quux:
1391 printf("But don't break the indentation of this instruction\n");
1392 break;
1393 }
1394}
1395
1396
1397void func(void)
1398{
Bram Moolenaaraede6ce2011-05-10 11:56:30 +02001399 cout << "a"
1400 << "b"
1401 << ") :"
1402 << "c";
1403}
1404
Bram Moolenaara4271d52011-05-10 13:38:27 +02001405
1406void func(void)
1407{
1408 /*
1409 * This is a comment.
1410 */
1411 foo();
1412}
1413
Bram Moolenaar334adf02011-05-25 13:34:04 +02001414
1415void func(void)
1416{
1417 for (int i = 0; i < 10; ++i)
1418 if (i & 1) {
1419 foo(1);
1420 } else
1421 foo(0);
1422 baz();
1423}
1424
Bram Moolenaared38b0a2011-05-25 15:16:18 +02001425
Bram Moolenaar3675fa02012-04-05 17:17:42 +02001426void func(void)
1427{
1428 if (condition1
1429 && condition2)
1430 action();
1431 function(argument1
1432 && argument2);
1433
1434 if (c1 && (c2 ||
1435 c3))
1436 foo;
1437 if (c1 &&
1438 (c2 || c3))
1439 {
1440 }
1441
1442 if ( c1
1443 && ( c2
1444 || c3))
1445 foo;
1446 func( c1
1447 && ( c2
1448 || c3))
1449 foo;
1450}
1451
1452
1453void func(void)
1454{
1455 if (condition1
1456 && condition2)
1457 action();
1458 function(argument1
1459 && argument2);
1460
1461 if (c1 && (c2 ||
1462 c3))
1463 foo;
1464 if (c1 &&
1465 (c2 || c3))
1466 {
1467 }
1468
1469 if ( c1
1470 && ( c2
1471 || c3))
1472 foo;
1473 func( c1
1474 && ( c2
1475 || c3))
1476 foo;
1477}
1478
1479
1480void func(void)
1481{
1482 if (condition1
1483 && condition2)
1484 action();
1485 function(argument1
1486 && argument2);
1487
1488 if (c1 && (c2 ||
1489 c3))
1490 foo;
1491 if (c1 &&
1492 (c2 || c3))
1493 {
1494 }
1495 if (c123456789
1496 && (c22345
1497 || c3))
1498 printf("foo\n");
1499
1500 c = c1 &&
1501 (
1502 c2 ||
1503 c3
1504 ) && c4;
1505}
1506
1507
1508void func(void)
1509{
1510 if (condition1
1511 && condition2)
1512 action();
1513 function(argument1
1514 && argument2);
1515
1516 if (c1 && (c2 ||
1517 c3))
1518 foo;
1519 if (c1 &&
1520 (c2 || c3))
1521 {
1522 }
1523 if (c123456789
1524 && (c22345
1525 || c3))
1526 printf("foo\n");
1527
1528 if ( c1
1529 && ( c2
1530 || c3))
1531 foo;
1532
1533 a_long_line(
1534 argument,
1535 argument);
1536 a_short_line(argument,
1537 argument);
1538}
1539
1540
1541void func(void)
1542{
1543 if (condition1
1544 && condition2)
1545 action();
1546 function(argument1
1547 && argument2);
1548
1549 if (c1 && (c2 ||
1550 c3))
1551 foo;
1552 if (c1 &&
1553 (c2 || c3))
1554 {
1555 }
1556 if (c123456789
1557 && (c22345
1558 || c3))
1559 printf("foo\n");
1560}
1561
1562
1563void func(void)
1564{
1565 if (condition1
1566 && condition2)
1567 action();
1568 function(argument1
1569 && argument2);
1570
1571 if (c1 && (c2 ||
1572 c3))
1573 foo;
1574 if (c1 &&
1575 (c2 || c3))
1576 {
1577 }
1578 if (c123456789
1579 && (c22345
1580 || c3))
1581 printf("foo\n");
1582
1583 if ( c1
1584 && ( c2
1585 || c3))
1586 foo;
1587 func( c1
1588 && ( c2
1589 || c3))
1590 foo;
1591}
1592
1593
1594void func(void)
1595{
1596 if (condition1
1597 && condition2)
1598 action();
1599 function(argument1
1600 && argument2);
1601
1602 if (c1 && (c2 ||
1603 c3))
1604 foo;
1605 if (c1 &&
1606 (c2 || c3))
1607 {
1608 }
1609}
1610
1611
Bram Moolenaar6ec154b2011-06-12 21:51:08 +02001612NAMESPACESTART
Bram Moolenaared38b0a2011-05-25 15:16:18 +02001613/* valid namespaces with normal indent */
1614namespace
1615{
1616{
1617 111111111111;
1618}
1619}
1620namespace /* test */
1621{
162211111111111111111;
1623}
1624namespace // test
1625{
1626111111111111111111;
1627}
1628namespace
1629{
1630111111111111111111;
1631}
1632namespace test
1633{
1634111111111111111111;
1635}
1636namespace{
1637111111111111111111;
1638}
1639namespace test{
1640111111111111111111;
1641}
1642namespace {
1643111111111111111111;
1644}
1645namespace test {
1646111111111111111111;
1647namespace test2 {
164822222222222222222;
1649}
1650}
1651
1652/* invalid namespaces use block indent */
1653namespace test test2 {
1654 111111111111111111111;
1655}
1656namespace11111111111 {
1657 111111111111;
1658}
1659namespace() {
1660 1111111111111;
1661}
1662namespace()
1663{
1664 111111111111111111;
1665}
1666namespace test test2
1667{
1668 1111111111111111111;
1669}
1670namespace111111111
1671{
1672 111111111111111111;
1673}
1674NAMESPACEEND
1675
1676
Bram Moolenaar6ec154b2011-06-12 21:51:08 +02001677
1678JSSTART
1679var bar = {
1680 foo: {
1681 that: this,
1682 some: ok,
1683 },
1684 "bar":{
1685 a : 2,
1686 b: "123abc",
1687 x: 4,
1688 "y": 5
1689 }
1690}
1691JSEND
1692
Bram Moolenaar76f7fd32011-07-20 15:09:43 +02001693
1694JSSTART
1695var foo = [
16961, // indent 8 more
1697 2,
1698 3
1699 ]; // indent 8 less
1700JSEND
1701
1702
1703JSSTART
1704function bar() {
1705 var foo = [
1706 1,
1707 2,
1708 3
1709 ]; // indent 16 less
1710}
1711JSEND
1712
1713
1714JSSTART
1715(function($){
1716
1717 var class_name='myclass';
1718
1719 function private_method() {
1720 }
1721
1722 var public_method={
1723 method: function(options,args){
1724 private_method();
1725 }
1726 }
1727
1728 function init(options) {
1729
1730 $(this).data(class_name+'_public',$.extend({},{
1731 foo: 'bar',
1732 bar: 2, // indent 8 more
1733 foobar: [ // indent 8 more
1734 1, // indent 8 more
1735 2, // indent 16 more
1736 3 // indent 16 more
1737 ],
1738 callback: function(){ // indent 8 more
1739 return true; // indent 8 more
1740 } // indent 8 more
1741 }, options||{}));
1742 }
1743
1744 $.fn[class_name]=function() {
1745
1746 var _arguments=arguments;
1747 return this.each(function(){
1748
1749 var options=$(this).data(class_name+'_public');
1750 if (!options) {
1751 init.apply(this,_arguments);
1752
1753 } else {
1754 var method=public_method[_arguments[0]];
1755
1756 if (typeof(method)!='function') {
1757 console.log(class_name+' has no method "'+_arguments[0]+'"');
1758 return false;
1759 }
1760 _arguments[0]=options;
1761 method.apply(this,_arguments);
1762 }
1763 });
1764 }
1765
1766})(jQuery);
1767JSEND
1768
1769
1770JSSTART
1771function init(options) {
1772 $(this).data(class_name+'_public',$.extend({},{
1773 foo: 'bar',
1774 bar: 2,
1775 foobar: [
1776 1, // indent 8 more
1777 2, // indent 8 more
1778 3 // indent 8 more
1779 ],
1780 callback: function(){
1781 return true;
1782 }
1783 }, options||{}));
1784}
1785JSEND
1786
1787
1788JSSTART
1789(function($){
1790 function init(options) {
1791 $(this).data(class_name+'_public',$.extend({},{
1792 foo: 'bar',
1793 bar: 2, // indent 8 more
1794 foobar: [ // indent 8 more
1795 1, // indent 8 more
1796 2, // indent 16 more
1797 3 // indent 16 more
1798 ],
1799 callback: function(){ // indent 8 more
1800 return true; // indent 8 more
1801 } // indent 8 more
1802 }, options||{}));
1803 }
1804})(jQuery);
1805JSEND
1806