Indentation

When you expand nested code levels, the folded text in the nested code is indented. It starts at the beginning of the line with +instead of the beginning of the indent.

Do you know how to change it?

illustrating picture

+3
source share
2 answers

If you want the bend text to be indented at the same level as the first line of the fold, you need to add the indentation level to the foldtext layer:

function! MyFoldText()
    let indent_level = indent(v:foldstart)
    let indent = repeat(' ',indent_level)
    ...
    ...   
    return indent . txt
endfunction

Here, I assume the line txtis your existing foldtext, so all you have to do is add it to the end indent.

But I'm not sure that this is what you want to achieve.

EDIT:

, , , . +. , -, , indent . '+' . txt.

.

+6

, .vimrc:

set foldtext=MyFoldText()
set fillchars=fold:_

, , :

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

, , , , gustibus...

+1

All Articles