diff options
-rw-r--r-- | plugin/monocole.vim | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/plugin/monocole.vim b/plugin/monocole.vim new file mode 100644 index 0000000..f83ee08 --- /dev/null +++ b/plugin/monocole.vim @@ -0,0 +1,32 @@ +" Monocole.vim: creates folds around a text object, such that only that text +" object is visible. +" +" This is useful when working in a very big file and only want a portion of that +" file visible at a time. +if !exists('g:monocole_create_mappings') + let g:monocole_create_mappings = 1 +endif + +function! s:create_monocole(text) abort + set foldmethod=manual + silent! norm zE + + 0,'[-1fold + silent! ']+1,$fold +endfunction + +function! s:v_create_monocole() abort + set foldmethod=manual + silent! norm zE + + 0,'<-1fold + silent! '>+1,$fold +endfunction + +noremap <silent> <Plug>(monocole-create) :<C-u>silent!set operatorfunc=<SID>create_monocole<cr>g@ +vnoremap <silent> <Plug>(v-monocole-create) :<C-u>call <SID>v_create_monocole()<cr> + +if g:monocole_create_mappings + noremap <silent> <C-f> <Plug>(monocole-create) + vnoremap <silent> <C-f> <Plug>(v-monocole-create) +endif |