How do I insert n repetitions into Vim until the next line is aligned?

  question, vim

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-实现插入n个”-“号的功能,但是中间那一行需要手动输入。因为Comments的内容长度未知,每次都需要手动输入,有时还会出现对不齐的情况。不知道是否有办法在输入完Comments后,自动插入足够的”-“号跟上一行对齐呢?
在输入完Comments后,希望可以自动插入足够的*号跟上一行对齐

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.