Comments (3)
I could resolve this with your plugin as well.
nnoremap <silent><expr> zo foldclosed('.')==-1?
\ ':execute "normal \<Plug>(fold-cycle-open)"<CR>':
\ 'zo'
My remaining question is: how can I disable the periodic boundary condition, i.e. if everything is open, simply keep it this way?
P.S: And I have defined a similar command for zc
:
nnoremap <silent><expr> zc foldclosed('.')==-1?
\ ':execute "normal \<Plug>(fold-cycle-close)"<CR>':
\ 'zc'
from vim-fold-cycle.
Adding to your plugin the variable g:fold_cycle_enable_cycling
❯ git diff
diff --git a/autoload/fold_cycle.vim b/autoload/fold_cycle.vim
index df182ef..a975f78 100644
--- a/autoload/fold_cycle.vim
+++ b/autoload/fold_cycle.vim
@@ -330,7 +330,7 @@ function! fold_cycle#open() abort "{{{3
call s:d_msg("opening fold :1")
foldopen
return
- elseif s:max_closed_fold_level == s:fold_level
+ elseif s:max_closed_fold_level == s:fold_level && g:fold_cycle_enable_cycling
call s:d_msg("closing all folds")
call s:branch_close_all()
return
@@ -358,11 +358,11 @@ function! fold_cycle#close() abort "{{{3
return
endif
- if s:folded
+ if s:folded && g:fold_cycle_enable_cycling
call s:d_msg("opening all folds: is folded")
call s:open_branch()
return
- elseif s:max_open_fold_level == 0
+ elseif s:max_open_fold_level == 0 && g:fold_cycle_enable_cycling
call s:d_msg("opening all folds: s:max_open_fold_level = 0")
call s:open_branch()
return
diff --git a/plugin/fold_cycle.vim b/plugin/fold_cycle.vim
index 2dcac4d..215c1ab 100644
--- a/plugin/fold_cycle.vim
+++ b/plugin/fold_cycle.vim
@@ -19,6 +19,7 @@ endif
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
let g:fold_debug = get(g:, 'fold_cycle_debug', 0)
let g:fold_cycle_default_mapping = get(g:, 'fold_cycle_default_mapping', 1)
+let g:fold_cycle_enable_cycling = get(g:, 'fold_cycle_enable_cycling', 1)
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""}}}
" MAPPINGS {{{
and setting its value to zero in my vimrc
" Advanced Recursive/Iterative Folding Commands zo,zc,zO,zC
" Note: use `za` for built-in`zc`
nnoremap <silent><expr> zO foldclosed('.')==-1?
\ 'zczO':
\ 'zv'
nnoremap <silent><expr> zC foldclosed('.')==-1?
\ ':<C-u>call fold_cycle#close_all()<CR>':
\ 'zC'
nnoremap <silent><expr> zo foldclosed('.')==-1?
\ ':<C-u>let g:fold_cycle_enable_cycling=0<bar>call fold_cycle#open()<bar>let g:fold_cycle_enable_cycling=1 <CR>':
\ 'zo'
nnoremap <silent><expr> zc foldclosed('.')==-1?
\ ':<C-u>call fold_cycle#close()<CR>':
\ 'zc'
Now all the mappings work as I wanted.
from vim-fold-cycle.
I don't quite understand this at first glance. I'll leave this open as a reminder to take a look at it in the future
from vim-fold-cycle.
Related Issues (9)
- Add global fold cycling commands HOT 1
- disable vim-fold-cycle for specific FileType HOT 3
- not working in neovim without using zc or zM firstly. HOT 2
- when opening folds, should closed fold with lowest fold level and fold it first
- bell HOT 4
- add option to limit the levels cycled through
- Add option to enhance recursive `zC` to all nested folds HOT 9
- Must I use `zc` to fold a block to use vim-fold-cycle? HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from vim-fold-cycle.