Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

persistence of folds between tabs (or buffers in a window) #67

Open
jwhite510 opened this issue Sep 8, 2021 · 0 comments
Open

persistence of folds between tabs (or buffers in a window) #67

jwhite510 opened this issue Sep 8, 2021 · 0 comments

Comments

@jwhite510
Copy link

jwhite510 commented Sep 8, 2021

Hello,
the plugin looks very cool. I am very interested in the idea of
using multiple tabs within a window in vim, in addition to the normal tabs
of vim.

The reason I want to have multiple tabs per window is primarily to keep
the folds (im usually using manual folds) updated. And it seems that unfortunately this
plugin does not do what I hoped for.

What I really want is to preserve the exact view of the file
and update the folded lines dynamically as edits are made, as is done when a window is open in the current window or any other tab. So if a fold is present, and 3 new lines are added above the fold, the fold should be moved down 3 lines

I've used :mkview which kind of works, but does not update the folds like it would
if a window had remained open

I've also used this
https://vim.fandom.com/wiki/Avoid_scrolling_when_switch_buffers
but the problem with this is it does not update folded lines.

The problem I'm trying to explain can be produced as follows:

save the following as 'test.vim' and run this command with either neovim or vim
nvim -u NONE -S test.vim
vim -u NONE -S test.vim

" remove the files if they exist
:!rm filea.txt
:!rm fileb.txt
" create a test file (filea.txt)
:e filea.txt
normal! idont fold me
normal! 2odont fold me
normal! 4ofoldme
normal! 3odont fold me
" go to line 4
normal! 4gg
:set foldmethod=manual
" fold down 3 lines (all of the 'fold me' lines are now folded)
normal! zf3j

" make a split and send it to the next tab
" (just to reference at the end)
:sp
wincmd T
" return to the original tab
normal! gT

" create a vertical split
:vs

" open a new file in the first window and do some editing
:e fileb.txt
normal! ihello
:w

" go to the other window (with filea.txt)
wincmd w
" insert a new line
normal! 3gg
normal! onew line that should not be folded
:w

" now go back to the previous window
wincmd p
" and switch to the file a buffer
:b filea.txt
" actual behaviour:
" 'foldme' is visible in the current window
" desired behaviour:
" 'foldme should be hidden, as it is in the other window'
"
" notice that in the other tab (press gt)
" the fold has been properly updated even
" though that window was not in view when the
" edit was made

I'm considering writing my own plugin which achieves this with a set of floating windows in neovim. I think I would
make floating windows that are in a location that is off screen somewhere.
do you have any thoughts on this? I wish that I did not have to rely on floating windows and a neovim specific
solution to this problem. I think what I want could be achieved if there were somehow a way to hide windows
or set their height to 0, so the folds will still be updated as if they were open, just in another tab somewhere, but I want to be able to reference them quickly like your plugin does.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant