gvim - How to insert repeated symbols n times until aligned with the previous line in Vim?
为情所困
为情所困 2017-05-16 16:40:54
0
4
886

Recently I am using Vim to write some small scripts. When writing comments, I want to separate them in this way:
"------------------------------------------------ ---------
"-------------This is Comments ----------------------------
"------------------------------------------------ ---------
I know that ni- can be used to insert n "-" signs, but the middle line needs to be entered manually. Because the content length of Comments is unknown, it needs to be entered manually every time, and sometimes misalignment occurs. I wonder if there is a way to automatically insert enough "-" signs to align with the previous line after entering Comments?

为情所困
为情所困

reply all(4)
我想大声告诉你

Add this to your vimrc:

inoremap <expr> <C-r>* repeat('*', strdisplaywidth(getline(line('.')-1))-strdisplaywidth(getline('.')))

Then press <C-r>* when you need to use an asterisk to align with the previous line.

Another solution is to copy all the asterisks in the previous line before writing the text part, and then press gR where you need to write text to enter the virtual replacement mode, so you don’t have to count the asterisks.

巴扎黑

.Use of number. .

漂亮男人

I don’t know how to do it directly, but there is another way to achieve your needs, and it’s not troublesome:

1. Insert more symbols each time
2. Use block selection to delete redundant symbols at once

给我你的怀抱

Uh~, can you write three asterisks first, jump to the middle, and then press R?

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template