vim: bind ctrl+shift+aletter

680 views
Skip to first unread message

ping

unread,
Aug 8, 2012, 11:23:42 PM8/8/12
to Vim.use.G
guys:
is there a way to bind ctrl+shift+p differently that ctrl-p ?
google told me NO, since they are the same "key code".
just double check to experts here as last hope or any close workaround...

Gary Johnson

unread,
Aug 9, 2012, 1:00:55 AM8/9/12
to Vim.use.G
You can find out for yourself by entering insert mode and typing
Ctrl-V followed by each of the key combinations you want to try.
I tried on Linux using vim in a terminal and gvim and both key
combinations produced the same result in both cases: ^P. If Vim
doesn't distinguish between the key combinations in that situation,
it can't when you use them in mappings, either. See

:help i_CTRL-V

Regards,
Gary

Christian Brabandt

unread,
Aug 9, 2012, 4:11:43 PM8/9/12
to Vim.use.G
Hi ping!
Please read the faq:
http://vimhelp.appspot.com/vim_faq.txt.html#faq-20.4
and possibly also Question 20.5

regards,
Christian
--
Tote Goldfische sind praktische Lesezeichen f�r B�cher aus der
Leihb�cherei. Der wachsende Fischgeruch dient als einfache
Ged�chtnisst�tze zur rechtzeitigen B�cherr�ckgabe!

ping

unread,
Aug 9, 2012, 5:16:42 PM8/9/12
to Vim.use.G


On 08/09/2012 04:11 PM, Christian Brabandt wrote:
> Hi ping!
>
> On Mi, 08 Aug 2012, ping wrote:
>
>> guys:
>> is there a way to bind ctrl+shift+p differently that ctrl-p ?
>> google told me NO, since they are the same "key code".
>> just double check to experts here as last hope or any close workaround...
>
> Please read the faq:
> http://vimhelp.appspot.com/vim_faq.txt.html#faq-20.4
> and possibly also Question 20.5
>
> regards,
> Christian
>

thanks!
so quick conclusion is:
no way for ctrl-shift-c/v(like in gnome)
fn is the only choice (but not convenient)

side-topic:
speaking of the terminalApp interception, looks xterm is the one has
less (no?) of it, means "vim friendly". isn't it?





=========================================
20.5. Why does mapping the <C-...> key not work?

The only Ctrl-printable-key chords which Vim can reliably detect
(because they
are defined in the ASCII standard) are the following:

Ctrl-@ 0x00 NUL
Ctrl-A to Ctrl-Z 0x01 to 0x1A
Ctrl-a to Ctrl-z 0x01 to 0x1A
Ctrl-[ 0x1B ESC
Ctrl-\ 0x1C
Ctrl-] 0x1D
Ctrl-^ 0x1E
Ctrl-_ 0x1F
Ctrl-? 0x7F DEL

Most of these, however, already have a function in Vim (and some are
aliases of other keys: Ctrl-H and Bsp, Ctrl-I and Tab, Ctrl-M and Enter,
Ctrl-[ and Esc, Ctrl-? and Del).

The "safest" keys to use in Vim for the {lhs} of a mapping are the F
keys, with or without Shift: <F2> to <F12> and <S-F1> to <S-F12>. (Some
OSes, including mine, intercept Ctrl-Fn and Alt-Fn, which never reach an
application program such as vim or gvim).

You can try other combinations of Ctrl + any key, but they may either
not work everywhere (e.g. the terminal might not pass that key to Vim,
or they might have unintended side effects (e.g. mapping <C-I> means
also to map <Tab>).

Simon Ruderich

unread,
Aug 13, 2012, 6:32:55 PM8/13/12
to vim...@googlegroups.com
On Thu, Aug 09, 2012 at 05:16:42PM -0400, ping wrote:
> so quick conclusion is:
> no way for ctrl-shift-c/v(like in gnome)
> fn is the only choice (but not convenient)

That's not entirely correct. You can configure your terminal
emulator to send a different keycode for ctrl-shift-c/v if your
emulator supports it - and then map that other key in Vim
(obviously works only for terminal Vim).

For example rxvt-unicode supports remapping the input. The
following entry in .Xdefaults remaps Ctrl-Shift-c to esc x (just
an example, you could also use the F* keys or any other unused
key):

URxvt.keysym.Control-0x43: \033x

0x43 is the keycode for upper c. Shift-c or Shift-0x63 (0x63 is
c) doesn't work!

Reload the changes:

$ xrdb -merge ~/.Xdefaults

Then open a new urxvt window and remap the key in Vim:

:map <esc>x ...

This should work for any key combination, use xev to get the
keycode for the desired combination. The rxvt man page has
additional information:

$ man urxvt | less -p ' keysym.sym'

Regards,
Simon
--
+ privacy is necessary
+ using gnupg http://gnupg.org
+ public key id: 0x92FEFDB7E44C32F9
Reply all
Reply to author
Forward
0 new messages