Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use customized key to start visual block selection in VIM

Tags:

vim

I know VIM can start visual block selection with Ctrl+V, or sometimes Ctrl+V becomes pasting, we can still go with Ctrl+Q. But I think this key combination is not so easy to press, can I assign a customized key for this? For example, I would like to use q in normal mode to start visual selection (I don't use macro recording that much):

map q ??? <-- what should I write here?

like image 598
pluskid Avatar asked Nov 12 '12 02:11

pluskid


People also ask

How do I select a visual block in vim?

Press v to begin character-based visual selection, or V to select whole lines, or Ctrl-v or Ctrl-q to select a block. Move the cursor to the end of the text to be cut/copied. While selecting text, you can perform searches and other advanced movement. Press d (delete) to cut, or y (yank) to copy.

What is Ctrl Q in Vim?

In your terminal, pressing <c-q> will sent stty start signal. This is important when you first stop your terminal output scrolling(by ctrl-s ), and then you want to resume. That is, in terminal vim, if you pressed C-q , it will be captured first by terminal.

How do you select in visual mode?

While you are inside a visual mode, you can switch to another visual mode by pressing either v , V , or Ctrl-v . For example, if you're in line-wise visual mode and you want to switch to block-wise visual mode, just type Ctrl-v . Try it! This will start visual mode on the same selected area as the last visual mode.


1 Answers

I believe you're looking for

:nnoremap q <c-v>

But note that you won't be able to record macros unless you remap that too.

like image 146
Kevin Avatar answered Sep 19 '22 20:09

Kevin