Advertisement
Guest User

Untitled

a guest
Feb 15th, 2019
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VIM 0.72 KB | None | 0 0
  1. function Sep()
  2.     if &commentstring =~ "%s"
  3.         let tw = &textwidth > 0 ? &textwidth : 79
  4.         let cs = substitute(substitute(&commentstring, '%s\zs\s*\ze\S', "|", ""), '\S\zs\s*\ze%s', "|", "")
  5.         " let sf = substitute(substitute(&commentstring, '%s\zs\s*\ze\S', "|", ""), '.*%s', "", "")
  6.         " let pf = substitute(substitute(&commentstring, '\S\zs\s*\ze%s', "|", ""), '%s.*', "", "")
  7.         let rn = range(stridx(cs, "%s"), tw - strlen(cs) + 3)
  8.         let md = join(map(rn, {key, val -> val % 8 == 0 ? "^" : "-"}), "")
  9.         call append(line(".") - 1, substitute(cs, "%s", md, ""))
  10.     else
  11.         echoerr "Comment string is not defined in this buffer."
  12.     endif
  13. endfunction
  14.  
  15. command Sep :call Sep()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement