blob: c6d7c5064a685f786944c4b68e7684b044d7c224 [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("."))
Bram Moolenaar4a5a8dd2017-03-16 13:54:10 +010030:set sw&
Bram Moolenaar071d4272004-06-13 20:20:40 +000031:" test syntax folding
32:set fdm=syntax fdl=0
Bram Moolenaarec986472009-11-03 13:46:54 +000033:syn region Hup start="dd" end="ii" fold contains=Fd1,Fd2,Fd3
34:syn region Fd1 start="ee" end="ff" fold contained
35:syn region Fd2 start="gg" end="hh" fold contained
36:syn region Fd3 start="commentstart" end="commentend" fold contained
Bram Moolenaar071d4272004-06-13 20:20:40 +000037Gzk:call append("$", "folding " . getline("."))
38k:call append("$", getline("."))
Bram Moolenaarec986472009-11-03 13:46:54 +000039jAcommentstart Acommentend:set fdl=1
403j:call append("$", getline("."))
Bram Moolenaarf4d7f942010-02-24 14:34:19 +010041:set fdl=0
42zO j:call append("$", getline("."))
Bram Moolenaar071d4272004-06-13 20:20:40 +000043:" test expression folding
44:fun Flvl()
45 let l = getline(v:lnum)
46 if l =~ "bb$"
47 return 2
48 elseif l =~ "gg$"
49 return "s1"
50 elseif l =~ "ii$"
51 return ">2"
52 elseif l =~ "kk$"
53 return "0"
54 endif
55 return "="
56endfun
57:set fdm=expr fde=Flvl()
58/bb$
59:call append("$", "expr " . foldlevel("."))
60/hh$
61:call append("$", foldlevel("."))
62/ii$
63:call append("$", foldlevel("."))
64/kk$
65:call append("$", foldlevel("."))
66:/^last/+1,$w! test.out
Bram Moolenaar9d2c8c12007-09-25 16:00:00 +000067:delfun Flvl
Bram Moolenaard5f69332015-04-15 12:43:50 +020068:new
69iTest fdm=indent and :move bug END
70line2
71 Test fdm=indent START
72 line3
73 line4
74:set fdm=indent
75:1m1
762jzc:m0
77:%w >> test.out
Bram Moolenaar071d4272004-06-13 20:20:40 +000078:qa!
79ENDTEST
80
811 aa
822 bb
833 cc
844 dd {{{
855 ee {{{ }}}
866 ff }}}
877 gg
888 hh
899 ii
90a jj
91b kk
92last