1TESTING 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 If you just want to test normal indenting with default options, you can make 26 this a large number of lines. Just add all kinds of language constructs, 27 nested statements, etc. with valid syntax. 28 29- Optionally, add lines with INDENT_EXE after START_INDENT, followed by a Vim 30 command. This will be executed before indenting the lines. Example: 31 32 " START_INDENT 33 " INDENT_EXE let g:vim_indent_cont = 6 34 let cmd = 35 \ 'some ' 36 \ 'string' 37 " END_INDENT 38 39 Note that the command is not undone, you may need to reverse the effect for 40 the next block of lines. 41 42- Alternatively to indenting all the lines between START_INDENT and 43 END_INDENT, use an INDENT_AT line, which specifies a pattern to find the 44 line to indent. Example: 45 46 " START_INDENT 47 " INDENT_AT this-line 48 func Some() 49 let f = x " this-line 50 endfunc 51 " END_INDENT 52 53 Alternatively you can use INDENT_NEXT to indent the line below the matching 54 pattern. Keep in mind that quite often it will indent relative to the 55 matching line: 56 57 " START_INDENT 58 " INDENT_NEXT next-line 59 func Some() 60 " next-line 61 let f = x 62 endfunc 63 " END_INDENT 64 65 Or use INDENT_PREV to indent the line above the matching pattern: 66 67 " START_INDENT 68 " INDENT_PREV prev-line 69 func Some() 70 let f = x 71 " prev-line 72 endfunc 73 " END_INDENT 74 75It's best to keep the whole file valid for FILETYPE, so that syntax 76highlighting works normally, and any indenting that depends on the syntax 77highlighting also works. 78 79 80RUNNING THE TEST 81 82Before running the test, create a FILETYPE.ok file. You can leave it empty at 83first. 84 85Now run "make test" from the parent directory. After Vim has done the 86indenting you will see a FILETYPE.fail file. This contains the actual result 87of indenting, and it's different from the FILETYPE.ok file. 88 89Check the contents of the FILETYPE.fail file. If it is perfectly OK, then 90rename it to overwrite the FILETYPE.ok file. If you now run "make test" again, 91the test will pass and create a FILETYPE.out file, which is identical to the 92FILETYPE.ok file. The FILETYPE.fail file will be deleted. 93 94If you try to run "make test" again you will notice that nothing happens, 95because the FILETYPE.out file already exists. Delete it, or do "make clean", 96so that the text runs again. If you edit the FILETYPE.in file, so that it's 97newer than the FILETYPE.out file, the test will also run. 98