1
2 " fold text between context and specify
3 function! ShowRSpecContext()
4 let spec_idx = search('specify\s\+".\+"', 'Wbn', '^')
5 let ctx_idx = search('context\s\+".\+"', 'Wbn', '^')
6 if spec_idx && ctx_idx
7 exec (ctx_idx+1).','.(spec_idx-1).'fold'
8 endif
9 endfunction
10
11 " fold text between all contexts and specify lines
12 function! ShowRSpecAnnotation()
13 call cursor('$', 0)
14 try
15 foldo!
16 catch
17 endtry
18 let cur_line = line('$')
19 while cur_line > 0
20 let prev_spec = search('\(context\|specify\)\s\+".\+"', 'Wb', '^')
21 if ! prev_spec
22 break
23 endif
24 exec (prev_spec).','.cur_line.'fold'
25 let cur_line=prev_spec-1
26 endwhile
27 endfunction
28 command! Sx :call ShowRSpecContext()
29 command! Sa :call ShowRSpecAnnotation()
30