The chapter 28 of User Manual says the following about folding:
Folding is used to show a range of lines in the buffer as a single line on the screen.
And all the examples of folding that I've seen converts several lines to only one.
What I'm trying to do is to create a folding within one line. For example if I have the following line:
MyFunction (with, really, a, lot, of, parameters, which, make, my, line, too, long)
I'd like to be able to fold it this way:
MyFunction (+-- folded)
So far I have tried different things with no success:
I know that it's possible to use
set foldmethod=marker
to add marker in the text to fold lines to it doesn't seem to work within a line. For example the following doesn't work:MyFunction ( /*{{{*/ with, really, a, lot, of, parameters, which, make, my, line, too, long /*}}}*/)
I also know that it is possible to create folding using text objects: for example to fold a paragraph it is possible to use
zfap
wherezf
is the command to create a folding andap
the text object to fold. I've tried to extend that withzfi(
,zfa(
,zfib
orzfab
but that give the following:MyFunction (with, really, a, lot, of, parameters, which, make, my, line, too, long)/*{{{*//*}}}*/
Finally I tried it with visual selection:
vib
andzf
but the result is the same as the previous method.
So my questions are:
- Is it possible to use folding within a line? From what I have tried I think that folds might not be the good way to do it
- If so, how can I do it?
If it is not possible with foldings, what should I try to use to get my result?
A bonus point would be to have a method which wouldn't need to add markers like
/*{{{*/
and/*}}}*/
in my buffer but if it's the only way to do it I'm ok with that.
&foldexpr
), and the&foldtext
function as well. I've done similar things in VimFold4C, except I've never tried to fold only one line. I don't know if this is possible. But what about the conceal feature?:h 'foldexpr'
saysit is evaluated for each line to obtain its fold level
so I guess that wouldn't work on a single line. I don't know very well theconceal
feature but from what I've read it might be the good way to go indeed. Thanks for the heads up!