You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
With 'foldcolumn' set to a positive integer, display a foldcolumn no matter what.
Desired behavior
With 'foldcolumn' set to auto, display a foldcolumn if folds are presents; otherwise, display no foldcolumn.
Thoughts
This would of course require Vim to be able to detect if folds are present in a file (based on fold method, or just searching around for them?). There would also need to be a discussion of how wide the auto-foldcolumn could be.
Current workaround
I found this somewhere, StackOverflow I think, that achieves the result but isn't perfect (I get a Terminal bell on almost all BufLoads because of the way folds are detected).
" Detects if folds present, sets foldcolumn to 2 if true or 0 if false" From http://stackoverflow.com/questions/8757168/gvim-automatic-show-foldcolumn-when-there-are-folds-in-a-filefunction!HasFolds()
"Attempt to move between folds, checking line numbers to see if it worked."If it did, there are folds.function!HasFoldsInner()
let origline=line('.')
:norm zkif origline==line('.')
:norm zjif origline==line('.')
return0elsereturn1endifelsereturn1endifreturn0endfunctionletl:winview=winsaveview()"save window and cursor positionlet foldsexist=HasFoldsInner()
if foldsexist
setfoldcolumn=2else"Move to the end of the current fold and check again in case the"cursor was on the sole fold in the file when we checkedifline('.')!=1
:norm [z
:norm kelse
:norm ]z
:norm jendiflet foldsexist=HasFoldsInner()
if foldsexist
setfoldcolumn=2elsesetfoldcolumn=0endifendcallwinrestview(l:winview)"restore window/cursor positionendfunction" Automatically add foldcolumn if folds presentauBufWinEnter?*callHasFolds()
The text was updated successfully, but these errors were encountered:
Current behavior
With
'foldcolumn'
set to a positive integer, display a foldcolumn no matter what.Desired behavior
With
'foldcolumn'
set toauto
, display a foldcolumn if folds are presents; otherwise, display no foldcolumn.Thoughts
This would of course require Vim to be able to detect if folds are present in a file (based on fold method, or just searching around for them?). There would also need to be a discussion of how wide the auto-foldcolumn could be.
Current workaround
I found this somewhere, StackOverflow I think, that achieves the result but isn't perfect (I get a Terminal bell on almost all BufLoads because of the way folds are detected).
The text was updated successfully, but these errors were encountered: