blob: b1e8266ab6fcc0e79653ee83e2d23fe9aae41f7d [file] [log] [blame]
Bram Moolenaar071d4272004-06-13 20:20:40 +00001Tests for folding. vim: set ft=vim :
2
3STARTTEST
4:so small.vim
5:" We also need the +syntax feature here.
6:if !has("syntax")
7 e! test.ok
8 w! test.out
9 qa!
10:endif
11:" basic test if a fold can be created, opened, moving to the end and closed
12/^1
13zf2j:call append("$", "manual " . getline(foldclosed(".")))
14zo:call append("$", foldclosed("."))
15]z:call append("$", getline("."))
16zc:call append("$", getline(foldclosed(".")))
17:" test folding with markers.
18:set fdm=marker fdl=1 fdc=3
19/^5
20:call append("$", "marker " . foldlevel("."))
21[z:call append("$", foldlevel("."))
22jo{{ r{jj:call append("$", foldlevel("."))
23kYpj:call append("$", foldlevel("."))
24:" test folding with indent
25:set fdm=indent sw=2
26/^2 b
27i jI :call append("$", "indent " . foldlevel("."))
28k:call append("$", foldlevel("."))
29:" test syntax folding
30:set fdm=syntax fdl=0
Bram Moolenaarec986472009-11-03 13:46:54 +000031:syn region Hup start="dd" end="ii" fold contains=Fd1,Fd2,Fd3
32:syn region Fd1 start="ee" end="ff" fold contained
33:syn region Fd2 start="gg" end="hh" fold contained
34:syn region Fd3 start="commentstart" end="commentend" fold contained
Bram Moolenaar071d4272004-06-13 20:20:40 +000035Gzk:call append("$", "folding " . getline("."))
36k:call append("$", getline("."))
Bram Moolenaarec986472009-11-03 13:46:54 +000037jAcommentstart Acommentend:set fdl=1
383j:call append("$", getline("."))
Bram Moolenaarf4d7f942010-02-24 14:34:19 +010039:set fdl=0
40zO j:call append("$", getline("."))
Bram Moolenaar071d4272004-06-13 20:20:40 +000041:" test expression folding
42:fun Flvl()
43 let l = getline(v:lnum)
44 if l =~ "bb$"
45 return 2
46 elseif l =~ "gg$"
47 return "s1"
48 elseif l =~ "ii$"
49 return ">2"
50 elseif l =~ "kk$"
51 return "0"
52 endif
53 return "="
54endfun
55:set fdm=expr fde=Flvl()
56/bb$
57:call append("$", "expr " . foldlevel("."))
58/hh$
59:call append("$", foldlevel("."))
60/ii$
61:call append("$", foldlevel("."))
62/kk$
63:call append("$", foldlevel("."))
64:/^last/+1,$w! test.out
Bram Moolenaar9d2c8c12007-09-25 16:00:00 +000065:delfun Flvl
Bram Moolenaard5f69332015-04-15 12:43:50 +020066:new
67iTest fdm=indent and :move bug END
68line2
69 Test fdm=indent START
70 line3
71 line4
72:set fdm=indent
73:1m1
742jzc:m0
75:%w >> test.out
Bram Moolenaar071d4272004-06-13 20:20:40 +000076:qa!
77ENDTEST
78
791 aa
802 bb
813 cc
824 dd {{{
835 ee {{{ }}}
846 ff }}}
857 gg
868 hh
879 ii
88a jj
89b kk
90last