--------...">

Change fold text

I noticed that folds can show useful information. Usually they show something like

+-- 5 lines: <div id="header-inner">--------------------------------------------

Is it possible to change the text in these lines? I noticed that something is possible in foldexpr , but is it possible to completely redo the folds?
eg
+ <div id="header-inner"> : "possible comment from line above" : row 27 : length 5

Thank you

+6
source share
2 answers

There are a few things that I don’t understand from your question, for example, which foldmethod you are using, or what is the number of β€œlines”, but here we use a special function foldtext, which should do something you want:

 function! MyFoldText() let nl = v:foldend - v:foldstart + 1 let comment = substitute(getline(v:foldstart),"^ *","",1) let linetext = substitute(getline(v:foldstart+1),"^ *","",1) let txt = '+ ' . linetext . ' : "' . comment . '" : length ' . nl return txt endfunction set foldtext=MyFoldText() 

Explanation:

  • Find the number of lines contained in the fold.
  • Get the β€œcomment” from the line before the first folded line (and remove the leading spaces).
  • Get text from the first line of the fold (and remove leading spaces).
  • Collect the above information in the returned folding text with the appropriate formatting.

Hope this helps. It should be easily adapted to your needs.

+10
source

You can also check the bend configuration from the repo page on the Lovs bitbucket vim website .

It has a very beautiful appearance, which is also very organized!

To find out what it is, you can record it in youtuebe video .

0
source

Source: https://habr.com/ru/post/887958/


All Articles