开发者

Indenting fold text

When you unfo开发者_Python百科ld nested levels of your code the folded text in nested code is not indented. It begins on the beginning of the line with + instead of starting indented.

Do you know how to change it?

Indenting fold text


If you want the fold text to be indented at the same level as the first line of the fold, you need to prepend the indent level to the foldtext:

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

Here I am assuming that the string txt is your existing foldtext, so all you need to do is add it to the end of indent.

But I am not sure if that is what you want to achieve.

EDIT:

Now I have seen your picture, I'm not sure if this is what you want. You could try stripping the leading whitespace before appending to the +. So the foldtext you want will be something like indent . '+' . txt.

Maybe.


Aha

You might want to comment out this function in your .vimrc:

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

This is what makes your fold text appearing non default, by using the function:

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

As it happens, I quite like that function, but of course, de gustibus...

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜