Reputation: 8587
In Vim you can use Ctrl+v to select a vertical block of code. This is pretty cool, as this way you can insert a rectangular block of text anywhere in your text. A feature I haven't seen anywhere else yet.
But say I have a text like:
1 abcde
2 abcdefg
3 abcdefg
4 abc
I want to select this full block as vertical block. If I'm on the a
of line 1, and start selection, then move down to line 4, I can only move the cursor to the last character c
in that line. So the lines above are cut off, giving me this selection:
1 abc
2 abc
3 abc
4 abc
Is there a way to get the full text selected as vertical block?
Upvotes: 0
Views: 2528
Reputation: 195029
if you want to select exact 4 lines (including the 1st line), you could:
Ctrl-V$3j
this selects all the texts, but they are not really in a "block", because the first line and the last line have different length.
If you do want have a "block" of text, (appending spaces on those "shorter" lines), you could:
set ve=all
Ctrl-V hhhhh... jjjjj...
by setting ve
to all
, your cursor could go anywhere. If you like after the selection/copying, you could set the ve
back to its original value.
Upvotes: 2
Reputation: 8587
A minute after asking this question i found it out myself. The trick is to press $ on line 4 above. So the full series of keystrokes, if the cursor is on the a
of line 1 is:
Ctrl+v3j$
Upvotes: 1
Reputation: 3185
a quick and dirty solution is to insert 4 spaces a the end of line 4.
Upvotes: 0