Reputation: 135
I got this
______0______
/ \
__7__ __3__
/ \ / \
0 4 9 8
/ \ / \ / \ / \
7 7 0 4 6 0 3 2
______another______
/ \
__block__ __just__
/ \ / \
aside the first one
I'd like that
______0______ ______another______
/ \ / \
__7__ __3__ __block__ __just__
/ \ / \ / \ / \
0 4 9 8 aside the first one
/ \ / \ / \ / \
7 7 0 4 6 0 3 2
Is there kind of "mutliline block" copy/cut and paste in vim ?
Upvotes: 1
Views: 606
Reputation: 196556
There is no magical way to achieve that but it is doable with :help visual-block
and some planning.
First, the naive approach, with visual-block mode:
Put the cursor on the first column of the line containing another
.
Press <C-v>
to enter visual-block mode, then jjjj
to expand the block downward, and $
to expand it to the end of each line.
Cut it with d
.
Move the cursor to the end of the line containing 0
and press p
to put what you just cut.
The horror:
______0______ ______another______
/ / \ \
__7__ _ __block__ __just__ _3__
/ \ / / \ / \ \
0 4 9 aside the first one 8
/ \ / \ / \ / \
7 7 0 4 6 0 3 2
The problem is that putting "block text" (by lack of a better word) is done "in place", without adding padding or assuming anything about the user's intent.
In order to put that "block text" at the right position, you need to add some padding yourself:
Put the cursor on the first column of the line containing another
.
Press <C-v>
to enter visual-block mode, then jjjj
to expand the block downward, and $
to expand it to the end of each line.
Cut it with d
.
Move the cursor to the end of the line containing 0
, append as many spaces as necessary with A<Space><Space><Space>
, and press p
to put what you just cut.
Much better:
______0______ ______another______
/ \ / \
__7__ __3__ __block__ __just__
/ \ / \ / \ / \
0 4 9 8 aside the first one
/ \ / \ / \ / \
7 7 0 4 6 0 3 2
NOTE: :help 'virtualedit'
can be of use, too, but it can necessitate special care so I prefer the simplicity of adding padding manually.
Upvotes: 3