blob: 751e1378fb7db0e651e1f73bd19603ea8e0bb311 [file] [log] [blame]
Bram Moolenaar071d4272004-06-13 20:20:40 +00001Tests for folding. vim: set ft=vim :
2
3STARTTEST
4:so small.vim
Bram Moolenaarc3c766e2017-03-08 22:55:19 +01005:set belloff=all
Bram Moolenaar071d4272004-06-13 20:20:40 +00006:" We also need the +syntax feature here.
7:if !has("syntax")
8 e! test.ok
9 w! test.out
10 qa!
11:endif
12:" basic test if a fold can be created, opened, moving to the end and closed
13/^1
14zf2j:call append("$", "manual " . getline(foldclosed(".")))
15zo:call append("$", foldclosed("."))
16]z:call append("$", getline("."))
17zc:call append("$", getline(foldclosed(".")))
18:" test folding with markers.
19:set fdm=marker fdl=1 fdc=3
20/^5
21:call append("$", "marker " . foldlevel("."))
22[z:call append("$", foldlevel("."))
23jo{{ r{jj:call append("$", foldlevel("."))
24kYpj:call append("$", foldlevel("."))
25:" test folding with indent
26:set fdm=indent sw=2
27/^2 b
28i jI :call append("$", "indent " . foldlevel("."))
29k:call append("$", foldlevel("."))
30:" test syntax folding
31:set fdm=syntax fdl=0
Bram Moolenaarec986472009-11-03 13:46:54 +000032:syn region Hup start="dd" end="ii" fold contains=Fd1,Fd2,Fd3
33:syn region Fd1 start="ee" end="ff" fold contained
34:syn region Fd2 start="gg" end="hh" fold contained
35:syn region Fd3 start="commentstart" end="commentend" fold contained
Bram Moolenaar071d4272004-06-13 20:20:40 +000036Gzk:call append("$", "folding " . getline("."))
37k:call append("$", getline("."))
Bram Moolenaarec986472009-11-03 13:46:54 +000038jAcommentstart Acommentend:set fdl=1
393j:call append("$", getline("."))
Bram Moolenaarf4d7f942010-02-24 14:34:19 +010040:set fdl=0
41zO j:call append("$", getline("."))
Bram Moolenaar071d4272004-06-13 20:20:40 +000042:" test expression folding
43:fun Flvl()
44 let l = getline(v:lnum)
45 if l =~ "bb$"
46 return 2
47 elseif l =~ "gg$"
48 return "s1"
49 elseif l =~ "ii$"
50 return ">2"
51 elseif l =~ "kk$"
52 return "0"
53 endif
54 return "="
55endfun
56:set fdm=expr fde=Flvl()
57/bb$
58:call append("$", "expr " . foldlevel("."))
59/hh$
60:call append("$", foldlevel("."))
61/ii$
62:call append("$", foldlevel("."))
63/kk$
64:call append("$", foldlevel("."))
65:/^last/+1,$w! test.out
Bram Moolenaar9d2c8c12007-09-25 16:00:00 +000066:delfun Flvl
Bram Moolenaard5f69332015-04-15 12:43:50 +020067:new
68iTest fdm=indent and :move bug END
69line2
70 Test fdm=indent START
71 line3
72 line4
73:set fdm=indent
74:1m1
752jzc:m0
76:%w >> test.out
Bram Moolenaar071d4272004-06-13 20:20:40 +000077:qa!
78ENDTEST
79
801 aa
812 bb
823 cc
834 dd {{{
845 ee {{{ }}}
856 ff }}}
867 gg
878 hh
889 ii
89a jj
90b kk
91last