3

Fold indicators in vim are prominent because they take up the entire window width:

  void foo() {
+--- 10 lines: int x;-----------------------------------------------------------
  }

which makes them distracting. Something like the following would be better:

  void foo() {
    [10 lines: int x;]
  }

Is this achievable in vim?

1 Answer 1

2

Yes, it's definitely possible. See (the single quotes are meant to be typed):

:help 'foldtext'

For example:

function! MyFoldText()
    let lines = printf('%' . len(line('$')) . 'd', v:foldend - v:foldstart + 1)
    let line  = substitute(foldtext(), '^+-\+ *\d\+ lines: ', '', '')

    return '[' . lines . ' lines: ' . line . ']'
endfunction

set foldtext=MyFoldText()

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .