How do you select a whole column in visual block mode?

Viewed 85024

Say that I have this simple text in (g)Vim:

a  b  c
a  b  c
a  b  c
a  b  c
a  b  c

after changing to visual block selection mode how can I can select the whole 3rd column? Ctrl+V G selects whole text. I am looking for a keyboard shortcut for selecting a whole column selection, if any exist.

Thanks.

6 Answers

I'm sure I'm not the only one who came here looking for a solution to a more general problem. Say I have:

Some text.

one two three
one two three
one two three
one two three
one two three
one two three

Some more text.

The following macro will select eg. all of the 'two' column when the cursor is anywhere inside it:

<C-v>iWmw{joO`woOmwoO}koO`w

How it works

  • <C-v>iW visual block select in Word (can of course have different macros for iw, a" etc.)
  • mw Set mark at the right boundary
  • {j Go to the start of the paragraph

Assuming you started somewhere in the middle, at this point your selection will look like this, where uppercase represents selected characters and $ represents the cursor:

Some text.

$NE Two three
ONE Two three
ONE Two three
one two three
one two three
one two three

Some more text.

oO swaps the cursor to the corner on the same side (left) but the other end (bottom):

Some text.

ONE Two three
ONE Two three
$NE Two three
one two three
one two three
one two three

Some more text.

`w will now get you back to the right boundary:

Some text.

one TWO three
one TWO three
one TW$ three
one two three
one two three
one two three

Some more text.

oOmwoO}koO`w repeats the process for going down to the bottom of the paragraph.

Result:

Some text.

one TWO three
one TWO three
one TWO three
one TWO three
one TWO three
one $WO three

Some more text.

If you are at the beginning of the first line you can do:

ww ............... jump to the third column
Ctrl-v } ......... jump to the end of paragraph

If you have a blank line after just type then:

gE ............... goes back to the end of third column

ctrl+shift+v is visual block. So just press ctrl+shift+v and then use cursor keys to select what you want. enter image description here

There is also ctrl+shift+I for block insert

Related