Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

VIM: Add spaces at cursor position

I would like to know if it is possible to add spaces (30 spaces) at cursor position

I tried to do it with regex but I don't know how to represent the actual cursor position in regex.

like image 480
Reman Avatar asked Apr 03 '11 09:04

Reman


People also ask

How do you add a space with multiple lines?

To insert individual spaces, click on the beginning of the line, then use cmd (for Mac) or ctrl (for Windows) and click on the beginning of other lines. It's the same way as how you select multiple files at once. Now when you add a space in front, it will add to all the lines that you selected.

How do you add a space with multiple lines in vi?

When you selected the desired lines of the block you want, you can press I (that is Shift + i ), you are now on insert mode, where you can add space in front of your line.


2 Answers

30iSPACE will add 30 spaces at the cursor position in command mode.

like image 196
khachik Avatar answered Oct 14 '22 17:10

khachik


  1. You can use vim register for this:

"a defines register a and if you cut a whitespace with "ax makes register a has whitespace. Then use:

30"ap

  1. Cut a whitespace with x and paste it with 30p

Note: Registers don't forget its value so first solution is more useful.

like image 34
xaph Avatar answered Oct 14 '22 16:10

xaph