Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to map Ctrl+A and Ctrl+Shift+A differently?

In a terminal, one cannot distinguish Ctrl+A and Ctrl+Shift+A as they both emit the same key code, so I can see why Vim can't do it. But gVim, being an X application, can differentiate Ctrl+A and Ctrl+Shift+A. Is there any way to map those two things differently?

For starters, I'd like to do something like the following: Make "paste from clipboard" work like Gnome terminal, while keeping Ctrl+V to the visual mode.

:nmap <C-S-V> "+gP 
like image 997
Kohsuke Kawaguchi Avatar asked Oct 01 '09 22:10

Kohsuke Kawaguchi


People also ask

What does Ctrl F do in Vim?

Ctrl+f will search within the file ctrl+shift+f will search in all the files in the folder tree.

What does ctrl t do in Vim?

The documentation isn't especially clear— CTRL + T is to jump back in the tag stack, whereas CTRL + O is to jump back to the previous cursor position.


1 Answers

Gvim doesn't do it because vim cannot do it (under normal circumstances). Sorry, but that's just how it is.


However...

Some terminals (e.g., xterm and iterm2) can be configured to send an arbitrary escape sequence for any combination of keys.

For example, add the following to .Xresources for xterm to send <Esc>[65;5u for CtrlShiftA. You can then map that in Vim to <C-S-a>. (65 is the decimal Unicode value for shift-a and 5 is the bit for the ctrl modifier. The u in this case stands for "unicode".)

! .Xresources XTerm*vt100.translations: #override Ctrl ~Meta Shift <Key>a: string(0x1b) string("[65;5u") 

iTerm and [u]rxvt can also be configured to do this (examples not provided).

More info: http://www.leonerd.org.uk/hacks/fixterms/

like image 93
graywh Avatar answered Oct 09 '22 08:10

graywh