tags:

views:

524

answers:

1

I have problems with automated splits and folding. In my ~/.gvimrc file, at the very end, I have the command vsplit, so that when I'm using gvim as opposed to vim, it opens with two panes. The problem occurs when I open a file that would normally be folded via the command line, as in gvim example.cpp. This opens the example.cpp file in two panes; however, the first pane is folded while the second is not. It's a minor annoyance, but I wondered if anyone had a suggestion to get the second (or all) buffers to be folded when the window first appears.

If it makes a difference, I use set foldmethod=indent in my ~/.vimrc file, and my version is 7.1.

+1  A: 

Hello, this is very strange, it also happens here, I'm guessing there must be a bug because other settings are valid on the second pane, except for the 'foldmethod' setting.

Anyway, I found an easy workaround. I have this at the end of my .vimrc and what you are looking for now works on my vim:

set foldmethod=indent
set sw=2
set tw=2

vsplit +edit

Now when I open a file, the window is split in two and both are folded correctly.

The workaround is executing the ex command :edit on the second pane so that the missing settings (although it seems that only 'foldmethod' is missing) are reloaded. That's what the +edit after the vsplit does.

Hope this resolves your problem.

Jorge Gajon
Thanks for the suggestion, Jorge. Unfortunately, with gvim adding this causes an error output to the console, and I need to hit enter to have vim continue processing. After that, it comes up with both folded, but the intermediate error is really a bummer. You did make me realize that I can "bufdo e" to reload all my files, which reapplies the folds, if I really want to.
Caleb Huitt - cjhuitt
I do not get any error at all with GVim, what error are you getting?
Jorge Gajon