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

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+VG selects whole text. I am looking for a keyboard shortcut for selecting a whole column selection, if any exist.

Thanks.


G goes to the last line, but moves the cursor to the first non-blank position if the startofline or compatible (which enables startofline ) options are set. If you want to keep the same column, set nosol before going into visual block mode, and then hit G.

From the manual entry for startofline :

When "on" the commands listed below move the cursor to the first non-blank of the line. When off the cursor is kept in the same column (if possible). This applies to the commands: CTRL-D, CTRL-U, CTRL-B, CTRL-F, "G", "H", "M", "L", gg, and to the commands "d", "<<" and ">>" with a linewise operator, with "%" with a count and to buffer changing commands (CTRL-^, :bnext, :bNext, etc.).


CTRL-V enters block selection mode (allowing you to select rectangular blocks of text). In gvim this conflicts with Windows' paste shortcut, so you can use CTRL-Q instead.

Unfortunately, CTRL-Q [G] doesn't do what you'd like since the [G] motion moves linearly through the file, so you still need to rely on a using a counted [j] motion. You can avoid having to know exactly how big the file is by using an obscenely large count, like 9999. So the full command is CTRL-Q [9999j].

Alas I don't know of way that will avoid the ugly count hack offhand.

EDIT: Oh, I read your question too fast and missed that you already mentioned that you new about the visual block mode. I guess this is a pretty useless answer, then, sorry!


The easy way for selecting column you can use plugin vis.vim

go to visual mode, select column ctrl+v , then you can do whatever you want with it

Use V, v or Ctrl+V to visually mark some region.Then type :B cmd (this command will appear as: :'<,'>B cmd )

The command will then be applied to just the visually selected region.

For example:

Use ctrl-v to select a column and then do a substitute on just that column.

Ctrl-V ..move.. :B s/pattern/becomes/

Use Ctrl-V to select a column, then apply an external filter to just that column:

Ctrl-V ..move.. :B !sort

链接地址: http://www.djcxy.com/p/49472.html

上一篇: 有什么方法可以在vim中删除而不会覆盖最后一次放弃?

下一篇: 如何在视觉模块模式中选择整个列?