aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJosh Rahm <rahm@google.com>2022-08-30 14:24:47 -0600
committerJosh Rahm <rahm@google.com>2022-08-30 14:24:47 -0600
commit5271196dd314b573ee0d0c3852ab5520b365ddd5 (patch)
tree7d9009e53fc23ddbf677fde8bd61fd3e43379e3f
parent80c891e10223e560c641589fe81be6fa07f0cf1f (diff)
downloadfieldmarshal.vim-5271196dd314b573ee0d0c3852ab5520b365ddd5.tar.gz
fieldmarshal.vim-5271196dd314b573ee0d0c3852ab5520b365ddd5.tar.bz2
fieldmarshal.vim-5271196dd314b573ee0d0c3852ab5520b365ddd5.zip
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.
-rw-r--r--plugin/monocole.vim32
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