docs:vim:folding_tests

folding tests

These tests are just to play with some folding ideas to see how different things can be done.

  1. load an example file of the specified language into vim
  2. type :new to split the window with an empty buffer
  3. type this to map the F5 key (or pick another one) to execute our test syntax and folding in the opposite window
    :map <F5> ggVGy<C-w><C-w>:@"<CR>
  4. copy the corresponding code block from below into the new empty buffer
  5. while in the empty buffer, press F5 to execute the code block on the opposite buffer window
syn clear
syn case ignore

syn region html start=/<\z\(html\)>/ end=/<\/\z1.*>/ contains=ALL fold
syn region head start=/<\z\(head\)>/ end=/<\/\z1.*>/ contains=ALLBUT,html,body fold
syn region body start=/<\z\(body\)\s*.*>/ end=/<\/\z1.*>/ contains=ALLBUT,html,head,body fold
syn region element start=/<\z\(style\|script\|form\|table\|ul\|ol\|div\).*>/ end=/<\/\z1.*>/ contains=ALLBUT,html,head,body fold
syn region comment start=/<!--/ end=/-->/ contains=ALLBUT,comment

set fen
set foldnestmax=20
set foldlevel=0
set foldmethod=syntax
syn sync fromstart
  • docs/vim/folding_tests.txt
  • Last modified: 2009/03/06 00:20
  • by billh