Recently, when writing some small scripts using Vim, when writing comments, I want to separate them in this way:
“————-This is Comments —————————-
I know you can use ni-
Add this to your vimrc:
inoremap <expr> <C-r>* repeat('*', strdisplaywidth(getline(line('.')-1))-strdisplaywidth(getline('.')))
Then press when you need to use an asterisk to align with the previous row.<C-r>*.
Another solution is to copy the previous line of asterisks before writing the text part, and then press where you need to write the text.gREnterVirtual replacement mode, so you don’t have to count asterisks.