Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Vim: how to select a rect area and do copy/paste

Tags:

vim

e.g.

1.1.1.1  a.com
2.1.1.1  b.com
1.3.1.1  c.com
1.1.5.1  d.com
1.2.1.1  e.com

now I want to replace this ip from another text, not the same width, like 111.222.111.222, is also store in a rect text.

I know that Ctrl+v can do rect select, but how to do copy and paste?

like image 238
guilin 桂林 Avatar asked Oct 20 '10 04:10

guilin 桂林


2 Answers

Ctrl-V, as you said, to select, then 'y' to "yank" (copy). You can then paste it with 'p'. You can select an area in which to paste by again using Ctrl-V and hitting 'p' instead of just hitting 'p'. Vim will respect the rectangular area that you copied when you do the pasting, so you won't need to reformat.

like image 128
siride Avatar answered Nov 18 '22 11:11

siride


In visual block mode (ctrl+v), highlight an area of your choice with the motion keys and then press "y" to copy the area, "p" to paste it (starting at the location of the cursor), or you can also press "x" to delete an highlighted area.

like image 24
ezrg Avatar answered Nov 18 '22 12:11

ezrg