mkview loadview problems

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

mkview loadview problems

Kamaraju Kusumanchi-3
In order to store and restore the previous state of .F90 files, I use

au! BufWinLeave *.F90 mkview
au! BufWinEnter *.F90 loadview

in my .vimrc . Most of the time it works fine. But sometimes the
closed folds become open when I edit the file next time. I think the
problem is due to the way the mkview writes the file.

In my ~/.vim/view/~\=+cvswork\=+fftw_and_mpi\=+fftw_and_mpi.F90\=  I
see multiple lines such as

311,320fold
311,320fold
311,320fold
311,320fold
311,320fold

Whenever I have repeated lines like this, the corresponding fold comes
open even though I would have closed it in the previous edit. Is there
any way to avoid this?

One hack I found is to open the file, go to line 311, then do zd zd zd
zd until it says E490: No fold found . Then I stop and create the fold
again by say, zf . But this method is cumbersome and I have to do it
for every fold that exhibits this behavior. A better solution would be
to say not to write repeated lines in the view file. Any
ideas/comments/suggestions are welcome.

thanks
raju
Reply | Threaded
Open this post in threaded view
|

Re: mkview loadview problems

Bram Moolenaar

Kamaraju Kusumanchi wrote:

> In order to store and restore the previous state of .F90 files, I use
>
> au! BufWinLeave *.F90 mkview
> au! BufWinEnter *.F90 loadview
>
> in my .vimrc . Most of the time it works fine. But sometimes the
> closed folds become open when I edit the file next time. I think the
> problem is due to the way the mkview writes the file.
>
> In my ~/.vim/view/~\=3D+cvswork\=3D+fftw_and_mpi\=3D+fftw_and_mpi.F90\=3D  =
> I
> see multiple lines such as
>
> 311,320fold
> 311,320fold
> 311,320fold
> 311,320fold
> 311,320fold
>
> Whenever I have repeated lines like this, the corresponding fold comes
> open even though I would have closed it in the previous edit. Is there
> any way to avoid this?
>
> One hack I found is to open the file, go to line 311, then do zd zd zd
> zd until it says E490: No fold found . Then I stop and create the fold
> again by say, zf . But this method is cumbersome and I have to do it
> for every fold that exhibits this behavior. A better solution would be
> to say not to write repeated lines in the view file. Any
> ideas/comments/suggestions are welcome.

The combination of mkview and loadview is supposed to restore the
situation exactly as it is.  Apparently you had that many folds for the
same line.  You might want to check out how these were created.  Solve
the problem where it's caused.

I didn't see the prolem with a fold being opened when trying it out.

--
We do not stumble over mountains, but over molehills.
                                Confucius

 /// Bram Moolenaar -- [hidden email] -- http://www.Moolenaar.net   \\\
///        Sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\              Project leader for A-A-P -- http://www.A-A-P.org        ///
 \\\     Buy LOTR 3 and help AIDS victims -- http://ICCF.nl/lotr.html   ///
Reply | Threaded
Open this post in threaded view
|

Re: mkview loadview problems

Kamaraju Kusumanchi-3
On 7/22/05, Kamaraju Kusumanchi <[hidden email]> wrote:

> > The combination of mkview and loadview is supposed to restore the
> > situation exactly as it is.  Apparently you had that many folds for the
> > same line.  You might want to check out how these were created.  Solve
> > the problem where it's caused.
> >
> > I didn't see the prolem with a fold being opened when trying it out.
>
> Thanks for the reply Bram. It took me sometime to figure out the problem.
>
> Consider I have two files file1.F90 and file2.F90
>
> as I have
>
> au! BufWinLeave *.F90 mkview
> au! BufWinEnter *.F90 loadview
>
> Everytime I open and close this file, it stores the 'status'.
>
> But sometimes I also do
>
> gvimdiff file1.F90 file2.F90
>
> now as gvimdiff defines its own folds etc., when I exit out of the
> gvimdiff, it again updates the status of file1.F90 and file2.F90 . I
> like the concept of folds in gvimdiff. So I do not want to get rid of
> this folding in gvimdiff. Is there any way to ask vim to update the
> status of *.F90 files after closing and only if it is not being edited
> through gvimdiff? May be some options to the above au commands?
>
> thanks
> raju
>

Ok. I got the solution after I posted this. I can do something like

if &diff
   ....
else
   ....
endif

If there is a better way please let me know.

thanks
raju

--
Please bottom post to my messages instead of top posting.