简体   繁体   中英

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.)

3 0 i SPACE将在命令模式下在光标位置添加30个空格。

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

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

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

除了已经给出的答案,我可以说光标位置在正则表达式中用\\%# ,所以s/\\%#/\\=repeat(" ", 30)/将在光标位置添加30个空格,就像30i<Space><Esc>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM