Tell Git to ignore .pyc files in icons folder
[MacVim.git] / src / testdir / test11.in
blob007698bac3d7815ee5991e296bbe859b8456e79d
1 Tests for autocommands:
2 - FileWritePre          writing a compressed file
3 - FileReadPost          reading a compressed file
4 - BufNewFile            reading a file template
5 - BufReadPre            decompressing the file to be read
6 - FilterReadPre         substituting characters in the temp file
7 - FilterReadPost        substituting characters after filtering
8 - FileReadPre           set options for decompression
9 - FileReadPost          decompress the file
11 Note: This test will fail if "gzip" is not available.
12 $GZIP is made empty, "-v" would cause trouble.
13 Use a FileChangedShell autocommand to avoid a prompt for "Xtestfile.gz" being
14 modified outside of Vim (noticed on Solaris).
16 STARTTEST
17 :so small.vim
18 :let $GZIP = ""
19 :au FileChangedShell * echo "caught FileChangedShell"
20 :set bin
21 :au FileWritePre    *.gz   '[,']!gzip
22 :au FileWritePost   *.gz   undo
23 :/^start of testfile/,/^end of testfile/w! Xtestfile.gz
24 :au FileReadPost    *.gz   '[,']!gzip -d
25 :$r Xtestfile.gz                " Read and decompress the testfile
26 :?startstart?,$w! test.out      " Write contents of this file
27 :au BufNewFile      *.c    read Xtest.c
28 :/^start of test.c/+1,/^end of test.c/-1w! Xtest.c
29 :e! foo.c                       " Will load Xtest.c
30 :au FileAppendPre   *.out  '[,']s/new/NEW/
31 :au FileAppendPost  *.out  !cat Xtest.c >>test.out
32 :w>>test.out                    " Append it to the output file
33 :au! FileAppendPre
34 :" setup autocommands to decompress before reading and re-compress afterwards
35 :au BufReadPre      *.gz   exe '!gzip -d ' . shellescape(expand("<afile>"))
36 :au BufReadPre      *.gz   call rename(expand("<afile>:r"), expand("<afile>"))
37 :au BufReadPost     *.gz   call rename(expand("<afile>"), expand("<afile>:r"))
38 :au BufReadPost     *.gz   exe '!gzip ' . shellescape(expand("<afile>:r"))
39 :e! Xtestfile.gz                " Edit compressed file
40 :w>>test.out                    " Append it to the output file
41 :set shelltemp                  " need temp files here
42 :au FilterReadPre   *.out  call rename(expand("<afile>"), expand("<afile>") . ".t")
43 :au FilterReadPre   *.out  exe '!sed s/e/E/ ' . shellescape(expand("<afile>")) . ".t >" . shellescape(expand("<afile>"))
44 :au FilterReadPre   *.out  exe '!rm ' . shellescape(expand("<afile>")) . '.t'
45 :au FilterReadPost  *.out  '[,']s/x/X/g
46 :e! test.out                    " Edit the output file
47 :23,$!cat
48 :23,$s/\r$//                 " remove CR for when sed adds them
49 :au! FileReadPre    *.gz   exe '!gzip -d ' . shellescape(expand("<afile>"))
50 :au  FileReadPre    *.gz   call rename(expand("<afile>:r"), expand("<afile>"))
51 :au! FileReadPost   *.gz   '[,']s/l/L/
52 :$r Xtestfile.gz             " Read compressed file
53 :w                           " write it, after filtering
54 :au!             " remove all autocommands
55 :e               " Edit test.out again
56 :set nobin ff&   " use the default fileformat for writing
58 :qa!
59 ENDTEST
61 startstart
62 start of testfile
63 line 2  Abcdefghijklmnopqrstuvwxyz
64 line 3  xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
65 line 4  Abcdefghijklmnopqrstuvwxyz
66 line 5  xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
67 line 6  Abcdefghijklmnopqrstuvwxyz
68 line 7  xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
69 line 8  Abcdefghijklmnopqrstuvwxyz
70 line 9  xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
71 line 10 Abcdefghijklmnopqrstuvwxyz
72 end of testfile
74 start of test.c
76  * Here is a new .c file
77  */
78 end of test.c