Tuesday, March 18, 2014

Re: Folding disapear when reopening the same file in a new window

On Tuesday, March 18, 2014 12:04:16 AM UTC-5, ale wrote:
> I find the filding feature too volatile.
>
>
>
> It disapears and expands way too often.
>
>

If your problem is during insert mode, here is a solution for most cases:

http://vim.wikia.com/wiki/Keep_folds_closed_while_inserting_text

>
> What bothers me the most, is when I fold manually, let's say, and reopen the
>
> same file in another window or another tab....what happens is that the
>
> folding in the first file is gone..
>

That is because folding is local to a window. Creating another window or tab will create a brand new set of folds for you. This is a FEATURE that lets you have multiple different views on a given file.

Actually re-reading that, you said the "folding in the first file is gone". Does that mean that opening a new window messes up folding in the first window? Or that the new window does not inherit the folding from the first window? I answered assuming the former. The latter should not be happening.

However, if you are using syntax folding, and insert some text which defines a fold in one window, that can mess up folding in other windows. That is one of the cases where the link I gave above doesn't help as much.

>
>
> I tried to manually set mkview...did not help
>
>

Did you then manually load the view? I am not perfectly clear from the help, but it may be the case that unless you specify a specific file name or view number, a new number will be used instead of overwriting an old one to allow multiple views on the same file. The help does say 'The combination of ":mkview" and ":loadview" can be used to store up to ten different views of a file.'

>
> I even tried to do the autocmd suggested in vim manual, so I copied the 2
>
> lines of:
>
>
>
> Au BufWinLeave *.c mkview
>
> Au BufWinEnter *.c loadview
>
>
>
> And still doesn't help.
>

The BufWinEnter autocmd will only fire if the file is not already visible in a window somewhere. In your case you are opening a new window.

BufWinLeave likewise only fires if this is the very last window on the file.

These autocmds are indended for saving/restoring a SINGLE view on the file between separate edit sessions. You are trying to lock multiple views to have a single set of folds in one edit session, which is a different problem altogether.

>
>
> So any suggestion to make the fold feature more controllable...because as
>
> for now..I feel like it decides on its own when to keep or get rid of the
>
> folding without any consistent and documented mannar
>

Consistent manner: any new window gets its own set of folds that updates independently of the other windows. This includes automatic updates for buffer content changes, even if you don't want those automatic updates.

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment