search

Home  >  Q&A  >  body text

vim - a piece of code to find code folding

Existing piece of folding code:

set fdm=expr
set foldexpr=Myindent(v:lnum)
func! Myindent(lnum)
    let s:a=strlen(matchstr(getline(v:lnum), '^\*\+\s\+\|^\d\(\.\d\)\=\s\+'))
    if s:a == 4
        return '>2'
    elseif s:a == 2
        return '>1'
    else
        return '='
    endif
endf

Text before folding:

Existing folding effects:

My needs:

  1. As shown in the picture below, how to remove the excess part in the front? It will look cleaner if you remove it
  2. I just started to contact Vim, I hope you can give me some advice

给我你的怀抱给我你的怀抱2743 days ago766

reply all(1)I'll reply

  • 迷茫

    迷茫2017-05-16 16:43:57

    :help fold-foldtext
    

    reply
    0
  • Cancelreply