7
|
1 Tests for folding. vim: set ft=vim :
|
|
2
|
|
3 STARTTEST
|
|
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
|
|
13 zf2j:call append("$", "manual " . getline(foldclosed(".")))
|
|
14 zo:call append("$", foldclosed("."))
|
|
15 ]z:call append("$", getline("."))
|
|
16 zc: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("."))
|
|
22 jo{{ r{jj:call append("$", foldlevel("."))
|
|
23 kYpj:call append("$", foldlevel("."))
|
|
24 :" test folding with indent
|
|
25 :set fdm=indent sw=2
|
|
26 /^2 b
|
|
27 i jI :call append("$", "indent " . foldlevel("."))
|
|
28 k:call append("$", foldlevel("."))
|
|
29 :" test syntax folding
|
|
30 :set fdm=syntax fdl=0
|
|
31 :syn region Hup start="dd" end="hh" fold
|
|
32 Gzk:call append("$", "folding " . getline("."))
|
|
33 k:call append("$", getline("."))
|
|
34 :" test expression folding
|
|
35 :fun Flvl()
|
|
36 let l = getline(v:lnum)
|
|
37 if l =~ "bb$"
|
|
38 return 2
|
|
39 elseif l =~ "gg$"
|
|
40 return "s1"
|
|
41 elseif l =~ "ii$"
|
|
42 return ">2"
|
|
43 elseif l =~ "kk$"
|
|
44 return "0"
|
|
45 endif
|
|
46 return "="
|
|
47 endfun
|
|
48 :set fdm=expr fde=Flvl()
|
|
49 /bb$
|
|
50 :call append("$", "expr " . foldlevel("."))
|
|
51 /hh$
|
|
52 :call append("$", foldlevel("."))
|
|
53 /ii$
|
|
54 :call append("$", foldlevel("."))
|
|
55 /kk$
|
|
56 :call append("$", foldlevel("."))
|
|
57 :/^last/+1,$w! test.out
|
|
58 :qa!
|
|
59 ENDTEST
|
|
60
|
|
61 1 aa
|
|
62 2 bb
|
|
63 3 cc
|
|
64 4 dd {{{
|
|
65 5 ee {{{ }}}
|
|
66 6 ff }}}
|
|
67 7 gg
|
|
68 8 hh
|
|
69 9 ii
|
|
70 a jj
|
|
71 b kk
|
|
72 last
|