Vim block macro

2023-04-05

Vim Digraphs (:dig) have those nice symbols ─ │ └ ┘ ....

Sometimes I like to make special comments in my files, like this:

# ┌───────────────────┐
# │ Here is a comment │
# └───────────────────┘
print("Hello!")

Unfortunately, I could not find a vim feature for this, so I wrote the following macro (you can put it for example into your .vimrc).

vmap \b rxgv:sort<cr>'>Yuma'>mb'aPVr<c-k>hhx4pY'bp<c-v>'akI<c-k>vv<esc>r<c-k>dr'bjr<c-k>urkl<c-v>'alI <esc>:set virtualedit=block<cr>'ak$<c-v>'bj$hr<c-k>vvr<c-k>dl'>$r<c-k>ul:set virtualedit=<cr>'all
nmap \b <nop>

One can use this macro works as follows: