Evan schrieb:
> So ever since folding showed up in vim I've been annoyed by some
> "behaviours".
Rule of thumb: If you're not sure that it is a bug, look in the help if
it can be customized.
> I assumed they were bugs and would be fixed in the next version, but
> they're still there many years later, and I'm finally wondering if
> maybe others don't see them, or maybe they're not considered bugs, or
> maybe I'm doing something wrong (though I don't see how since I just
> :set foldmethod=indent).
Might be that other people don't see these "behaviours", just because
they are using other methods of folding. I don't know how many people
actually use fdm=indent, Python programmers?
Anyway, Vim has many bugs waiting to be fixed:
:h todo.txt
I can't see anything regarding "foldmethod" and "indent".
> So here's what I see. Do other people see them? Do they get annoyed
> by them? Is there a reason they don't see them, or have a workaround
> for them?
>
> This is VIM 7.2:
>
> :set foldmethod=indent
>
> Now write a line, and then some indented lines under it, like
>
> a
> b
> c
>
> Now add something before 'a', hit return and tab. a b and c will all
> fold up, even though they were never folded to begin with! This is
> annoying when what you're editing suddenly folds up and disappears
> even though you just explicitly unfolded it.
You should try this again with
:set foldopen+=insert
:h 'fdo
> Put behaviour with folding is also surprising. If you put below a
> folded region and the put text is also indented, it will join the
> fold, which will stay closed.
I can imagine this is not always annoying.
> The effect is that the text you put immediately disappears and you
> have to open the fold and hunt for it. If you enter text into a fold
> with 'insert' it automatically opens, but if you enter text with put
> it doesn't. Shouldn't it open in both cases?
I don't think so, not in every case you are going to work on text that
you just put.
But in your case, try setting all 'foldopen' options:
:set foldopen=all
> But it's worse than that, if you have an indent which is open, then
> put something which is indented into it, the whole thing will fold up,
> even though it was explicitly unfolded earlier. I.e. in the 'a b c'
> above, type dd on 'c', then jP to put it above 'b', the whole thing
> should fold up. This is really annoying!
Hmm, might be this is a bug. What I see here (with default 'fdo'): If
the put text becomes the start of the fold, the fold will close. If
text is put below the first line of the fold, the fold will not close.
(text in the buffer and in the register had the same indent).
> This also happens if you do an undo that results in something being
> added to the open fold: it closes up automatically.
Let me again point you to 'foldopen' ;)
> Folds in indent mode also get out of sync with the buffer contents.
> If you have
>
> a
> b
> c
>
> and then append a blank line plus indented d and e, the folds won't
> combine, so you wind up with what should be one fold but is really
> two. This happens all the time when pasting stuff into functions and
> the result is a function that won't fold up. I can work around by
> setting foldmethod=indent again or switching to another buffer and
> back, but this seems more like a bug than a feature.
Yep, this looks like a bug. If I just insert
a
b
c
d
e
the resulting folds are (after zM ):
a
+-- 2 lines: b--------------------------------------------------
+-- 2 lines: d--------------------------------------------------
but it should be one fold:
a
+-- 5 lines: b--------------------------------------------------
which is the result after executing :setl fdm=indent .
--
Andy
--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---