From 5271196dd314b573ee0d0c3852ab5520b365ddd5 Mon Sep 17 00:00:00 2001 From: Josh Rahm Date: Tue, 30 Aug 2022 14:24:47 -0600 Subject: monocole.vim: add monocole.vim monocole adds mappings to fold text around a text object so only the text described by th egiven text object is available. --- plugin/monocole.vim | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 plugin/monocole.vim (limited to 'plugin') 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 (monocole-create) :silent!set operatorfunc=create_monocoleg@ +vnoremap (v-monocole-create) :call v_create_monocole() + +if g:monocole_create_mappings + noremap (monocole-create) + vnoremap (v-monocole-create) +endif -- cgit