Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function Sep()
- if &commentstring =~ "%s"
- let tw = &textwidth > 0 ? &textwidth : 79
- let cs = substitute(substitute(&commentstring, '%s\zs\s*\ze\S', "|", ""), '\S\zs\s*\ze%s', "|", "")
- " let sf = substitute(substitute(&commentstring, '%s\zs\s*\ze\S', "|", ""), '.*%s', "", "")
- " let pf = substitute(substitute(&commentstring, '\S\zs\s*\ze%s', "|", ""), '%s.*', "", "")
- let rn = range(stridx(cs, "%s"), tw - strlen(cs) + 3)
- let md = join(map(rn, {key, val -> val % 8 == 0 ? "^" : "-"}), "")
- call append(line(".") - 1, substitute(cs, "%s", md, ""))
- else
- echoerr "Comment string is not defined in this buffer."
- endif
- endfunction
- command Sep :call Sep()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement