blob: 8efd34ed4cfdfb84aae6761ab604c760baa0ac92 [file] [log] [blame]
Bram Moolenaarc0fe4972018-10-25 16:53:19 +02001TESTING INDENT SCRIPTS
2
3We'll use FILETYPE for the filetype name here.
4
5
6FORMAT OF THE FILETYPE.IN FILE
7
8First of all, create a FILETYPE.in file. It should contain:
9
10- A modeline setting the 'filetype' and any other option values.
11 This must work like a comment for FILETYPE. E.g. for vim:
12 " vim: set ft=vim sw=4 :
13
14- At least one block of lines to indent, prefixed with START_INDENT and
15 followed by END_INDENT. These lines must also look like a comment for your
16 FILETYPE. You would normally leave out all indent, so that the effect of
17 the indent command results in adding indent. Example:
18
19 " START_INDENT
20 func Some()
21 let x = 1
22 endfunc
23 " END_INDENT
24
25- Optionally, a line with INDENT_EXE, followed by a Vim command. This will be
26 executed before indenting the lines. Example:
27
28 " START_INDENT
29 " INDENT_EXE let g:vim_indent_cont = 6
30 let cmd =
31 \ 'some '
32 \ 'string'
33 " END_INDENT
34
35 Note that the command is not undone, you may need to reverse the effect for
36 the next block of lines.
37
38- Alternatively to indenting all the lines between START_INDENT and
39 END_INDENT, use a INDENT_AT line, which specifies a pattern to find the line
40 to indent. Example:
41
42 " START_INDENT
43 " INDENT_AT this-line
44 func Some()
45 let f = x " this-line
46 endfunc
47 " END_INDENT
48
49 Alternatively you can use INDENT_NEXT to indent the line below the matching
50 pattern:
51
52 " START_INDENT
53 " INDENT_NEXT next-line
54 func Some()
55 " next-line
56 let f = x
57 endfunc
58 " END_INDENT
59
60 Or use INDENT_PREV to indent the line above the matching pattern:
61
62 " START_INDENT
63 " INDENT_PREV prev-line
64 func Some()
65 let f = x
66 " prev-line
67 endfunc
68 " END_INDENT
69
70It's best to keep the whole file valid for FILETYPE, so that syntax
71highlighting works normally, and any indenting that depends on the syntax
72highlighting also works.
73
74
75RUNNING THE TEST
76
77Before running the test, create a FILETYPE.ok file. You can leave it empty at
78first.
79
80Now run "make test". After Vim has done the indenting you will see a
81FILETYPE.fail file. This contains the actual result of indenting, and it's
82different from the FILETYPE.ok file.
83
84Check the contents of the FILETYPE.fail file. If it is perfectly OK, then
85rename it to overwrite the FILETYPE.ok file. If you now run "make test" again,
86the test will pass and create a FILETYPE.out file, which is identical to the
87FILETYPE.ok file.
88
89If you try to run "make test" again you will notice that nothing happens,
90because the FILETYPE.out file already exists. Delete it, or do "make clean",
91so that the text runs again. If you edit the FILETYPE.in file, so that it's
92newer than the FILETYPE.out file, the test will also run.