VIM: Add spaces at cursor position

I would like to know if spaces (30 spaces) can be added to the cursor position

(I tried to do this with a regex, but I don't know how to represent the actual cursor position in a regex.)

+7
source share
3 answers

3 0 i SPACE will add 30 spaces to the cursor position in command mode.

+16
source

1- You can use the vim register for this:

"a defines case a, and if you cut the space with" ax makes case a has a space. Then use:

30 "ar

2- Cut whitspace with x and paste it using 30p

Note. Registers do not forget its meaning, so the first solution is more useful.

+3
source

In addition to the answers already provided, I can say that the cursor position is represented in regex with \%# , so s/\%#/\=repeat(" ", 30)/ will add 30 spaces to the cursor position, like 30i<Space><Esc> .

+2
source

All Articles