Eu tenho isso no meu .vimrc
:
vn<silent> <leader>[ :<c-u>cal<sid>rect(1)<cr>
vn<silent> <leader>] :<c-u>cal<sid>rect(2)<cr>
let s:h=split(' ╶╺╵└┕╹┖┗╴─╼┘┴┶┚┸┺╸╾━┙┵┷┛┹┻╷┌┍│├┝╿┞┡┐┬┮┤┼┾┦╀╄┑┭┯┥┽┿┩╃╇╻┎┏╽┟┢┃┠┣┒┰┲┧╁╆┨╂╊┓┱┳┪╅╈┫╉╋','\zs')
let s:e=map(range(81),'[v:val/27%3,v:val/9%3,v:val/3%3,v:val%3]') "base-3 encode
fu s:rect(x) "x:thickness
if visualmode()!=#"\<c-v>"|retu|en
let s=&sel|let&sel='inclusive'|let[ls,cs]=[[line("'<"),line("'>")],[virtcol("'<"),virtcol("'>")]]|let&sel=s
let[l0,l1,c0,c1]=[min(ls),max(ls),min(cs),max(cs)]
let a=map(map(getline(l0,l1),"split(v:val,'\zs')"),"extend(v:val,repeat([' '],max([0,c1-len(v:val)])))")
let x=a:x|let[V,H]=[[x,0,x,0],[0,x,0,x]] "vertical and horizontal line
"b:list of changes as [line,column,bitmask]
if l0<l1&&c0<c1|let b=[[l0,c0,[x,0,0,x]],[l0,c1,[x,x,0,0]],[l1,c0,[0,0,x,x]],[l1,c1,[0,x,x,0]]]
let b+=map(range(l0+1,l1-1),'[v:val,c0,V]')+map(range(l0+1,l1-1),'[v:val,c1,V]')
let b+=map(range(c0+1,c1-1),'[l0,v:val,H]')+map(range(c0+1,c1-1),'[l1,v:val,H]')
elsei l0<l1 |let b=[[l0,c0,[x,0,0,0]],[l1,c0,[0,0,x,0]]]+map(range(l0+1,l1-1),'[v:val,c0,V]')
elsei c0<c1 |let b=[[l0,c0,[0,0,0,x]],[l0,c1,[0,x,0,0]]]+map(range(c0+1,c1-1),'[l0,v:val,H]')
el |let b=[]|en
for[l,c,m]in b
let i=index(s:h,a[l-l0][c-1])
if i>=0|let z=map(copy(s:e[i]),'max([v:val,m[v:key]])')|let a[l-l0][c-1]=s:h[27*z[0]+9*z[1]+3*z[2]+z[3]]|en
endfo
cal setline(l0,map(a,"join(v:val,'')"))
endf
Selecionar um retângulo no modo visual de bloco ( <C-v>
) e pressionar <leader>[
coloca os caracteres de desenho de linha em sua borda, mesclando-os com qualquer caractere de desenho de linha pré-existente. Se você insistir em puro ASCII +-|
, deve ser fácil modificá-lo.