guilin 桂林
guilin 桂林

Reputation: 17412

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

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?

Upvotes: 9

Views: 8749

Answers (3)

ezrg
ezrg

Reputation: 11

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.

Upvotes: 1

Diego Torres Milano
Diego Torres Milano

Reputation: 69426

Select with CTRL-V and then motion keys. If you have set showmode you will see -- VISUAL BLOCK -- at the bottom.

Copy.

Select the destination again with CTRL-V.

Paste.

Upvotes: 0

siride
siride

Reputation: 210055

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.

Upvotes: 11

Related Questions