4

I have a custom foldexpr to fold comments in markdown. Is there a way to make this fold operation work on just one line? Even if it is just 1 line, I like the color change that folding applies so I can concentrate on non-comments.

1 Answer 1

6

'foldminlines' 'fml'    number (default: 1)
                        local to window
                        {not available when compiled without the +folding
                        feature}
        Sets the number of screen lines above which a fold can be displayed
        closed.  Also for manually closed folds.  With the default value of
        one a fold can only be closed if it takes up two or more screen lines.
        Set to zero to be able to close folds of just one screen line.
        Note that this only has an effect on what is displayed.  After using
        "zc" to close a fold, which is displayed open because it's smaller
        than 'foldminlines', a following "zc" may close a containing fold.

So do set foldminlines=0:

To test I did select a single line and pressed zf:

enter image description here

4
  • Awesome! Thank you for the solution. Unfortunately, as a new member I cannot mark this as an answer. If someone could mark it as an answer I would appreciate it. (Would you also enlighten me with your process as to how you found this setting?)
    – yh dev
    Commented Jan 20, 2022 at 7:47
  • @yhdev upvoted your question to bring some points to you. Welcome to Vi and Vim SE!
    – Maxim Kim
    Commented Jan 20, 2022 at 7:48
  • As for process -- it is just :h fold<C-d> to list every help topic that match fold-something... And then maybe tune it with :h fold*line<C-d> to narrow it down a bit
    – Maxim Kim
    Commented Jan 20, 2022 at 7:50
  • 1
    You will be able to accept the answer after some delay, I believe, @yhdev. No one besides the asker has the ability to mark an answer accepted.
    – D. Ben Knoble
    Commented Jan 20, 2022 at 14:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.