RE: folding out patterns
> Is there any prospect of "folding" out regexps in a future vim? ThisThis has been asked a few times before: as far as I
> form of "folding" would make regexp(s) invisible.
know, no-one has ever stepped up to do it - probably
because it has implications on cursor movement, just
as line folding does.
However, it can't be unsurmountable because the code
already differentiates between the screen column
and the line column - this is necessary for the
correct handling of tabs and virtual editing.
One thing that springs to mind as a possible sticking
point is that IIRC Vim renders to the screen on a line-by-line
basis. That means that if you had a file like this:
..and you wanted to "hide" the b's to leave
..then that might be hard. If you were
satisfied to not have hiding alter line
breaks, so that the above example yielded
then I imagine the implementation might be easier.
You would also need to specify what happens about
a search operation hitting the hidden text, whether
hidden text counts for CTRL-N/P insert mode completion,
etc... there are a lot of UI points to be settled one
way or the other.
If anyone is feeling brave enough to go after this...
The place to start from the display point of
view is win_line() in screen.c. You might begin
your experiments as follows:
1) munge win_line() so that for a given Syntax
group, text is displayed using a fixed character,
e.g. if "hello" is hidden, it's displayed as "XXXXX"
(obviously the 'X' character is an option)
2) once that's working, make it collapse text with
that attribute to a single character, e.g.
"hello" -> "X"
3) Now you have to deal with the cursor movement.
a) Understand how curs_columns() works and
make it cope with the collapsing of parts
of a line to a single character.
b) Temporarily disable collapsing for the
cursor line at all times. This means you
have to schedule more redraws as the
cursor moves about, but is possibly easier.
3a) Deal with all the unexpected side effects
you haven't thought of :)
4) If all *that* works, including working for
virtual edit and multibyte :-), then see
if you can make the hidden areas collapse
to zero width instead of one character.
5) Clean up patch.
6) Write docs!
7) Post patch to list and receive adulation :-)