"============================================================================= " exprfold.vim --- SpaceVim exprfold layer " Copyright (c) 2016-2021 Wang Shidong & Contributors " Author: Wang Shidong < wsdjeg at 163.com > " URL: https://spacevim.org " License: GPLv3 "============================================================================= "" " @section exprfold, layers-exprfold " @parentsection layers " Fold code quickly according to expr. " " Mappings: " > " Key Mode Function " ---------------------------------------------------- " ZB normal Open fold block template " ZF normal Fold block " ZC normal Fold block comment " < function! SpaceVim#layers#exprfold#health() abort call SpaceVim#layers#exprfold#plugins() call SpaceVim#layers#exprfold#config() return 1 endfunction function! SpaceVim#layers#exprfold#plugins() abort return [ \ ['ZSaberLv0/ZFVimFoldBlock', {'merged' : 0}], \ ] endfunction function! SpaceVim#layers#exprfold#config() abort nnoremap ZB q::call ZF_FoldBlockTemplate() nnoremap ZF :ZFFoldBlock // function! ZF_Plugin_ZFVimFoldBlock_comment() abort let expr='\(^\s*\/\/\)' if &filetype ==# 'vim' let expr.='\|\(^\s*"\)' endif if &filetype ==# 'c' || &filetype ==# 'cpp' let expr.='\|\(^\s*\(\(\/\*\)\|\(\*\)\)\)' endif if &filetype ==# 'make' let expr.='\|\(^\s*#\)' endif let disableE2vSaved = g:ZFVimFoldBlock_disableE2v let g:ZFVimFoldBlock_disableE2v = 1 call ZF_FoldBlock('/' . expr . '//') let g:ZFVimFoldBlock_disableE2v = disableE2vSaved echo 'comments folded' endfunction nnoremap ZC :call ZF_Plugin_ZFVimFoldBlock_comment() endfunction