Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

vim: Use ctrl-Q for visual block mode in vim-gnome

Tags:

vim

I use vim on windows and linux. On linux I would like to set ctrl-Q to visual block selection, but still maintain behave mswin which sets ctrl-v to paste.

How can I keep behave mswin and use ctrl-Q for visual block mode?

edit: I though mswin would also map ctrl-Q to visual block mode, but in vim-gnome ctrl-Q does nothing

like image 774
red888 Avatar asked Feb 16 '14 01:02

red888


1 Answers

first of all, I highly recommend you to forget the windows vim shortcuts if you work on a linux box. such as: ctrl-v, ctrl-q, ctrl-c ...

well you must think this isn't the answer to your question. now I post the "answer".

to make ctrl-q work as ctrl-v (block selection) on a linux box, you have to tell, you work with gvim or vim in terminal.

Gvim

If it was gvim, it is easier, just create a mapping, like:

nnoremap <c-q> <c-v>

Terminal Vim

If you want to make <c-q> work in your terminal vim, you need to understand the default <C-q> has special meaning in your terminal settings.

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. You can of course change that rule, by disable the stty start definition. like:

stty start undef

you could add this to your .bashrc file (I assume you were using bash) if you want to make it as default.

with this line executed, you can create the same mapping nnoremap <c-q> <c-v> in your vim, and pressing <c-q> in normal mode, vim is gonna enter block-wise selection mode.

After all, again, I suggest you forget the windows mapping if you work on linux box.

like image 75
Kent Avatar answered Nov 15 '22 09:11

Kent