TheT
TheT

Reputation: 31

Is there a way to fold less than a line in vim?

since I´m doing a lot of latex editing in vim, I was wondering if it´s possible to fold only parts of a line.

For example: I´d like to fold "\section{Hello}" simply to "Hello"(in another color) or \footnote{hi!} to "[hi!]" or even just "[1]".

Is that somehow possible? It doesn´t necessarily have to use folds, just some kind of "alias" or so would do it, since I just want to improve readability of my text.

Do you have any idea how to realize this?

Thanks for your help!

I found out so far, that it is possible to change the text in folds so I could solve the section part creating just a one line fold with a different text as in I want to customize the text vim shows in collapsed folds

Upvotes: 3

Views: 661

Answers (3)

intuited
intuited

Reputation: 24034

This sort of thing can apparently be done using the conceal patch, which has been rolled into vim 7.3. It allows certain parts of the text to be, well, concealed from view.

caveat: I don't code (la)?tex, I haven't upgraded to vim 7.3, and I've never used the conceal patch.

Of course, knowledge of the conceal patch's existence, while no doubt terribly exciting, only gets you part way. A blog post, which I admittedly didn't really read, may be of further assistance. It looks like they're doing something somewhat different from what you're aiming to accomplish: using conceal to map latex-denoted symbols to their corresponding unicode characters. But it might be helpful nonetheless and serve as a starting point for building a custom tex syntax file that uses conceal to accomplish your goal.

Actually, it looks like the latex syntax file for 7.3 may already be using conceal to remap characters. This mailing list thread has a bit more information.

Upvotes: 3

sehe
sehe

Reputation: 392833

You can use the trick you mentioned to manipulate the foldtext.

Now :set foldminlines=0 in order to enable folding a single line.

Create a single line fold to test with using Vzf

Subsequently fold/open (z[cCM] or z[oOR]) it and test your foldtext expression until it suits your needs.

HTH

Upvotes: 3

moritz
moritz

Reputation: 5224

vim-latex offers some folding, for me it is enough, see folding.

Upvotes: 0

Related Questions