Problems with mappings using the Shift in the terminal

43 views
Skip to first unread message

Pablo Giménez

unread,
Apr 28, 2009, 1:53:18 PM4/28/09
to vim...@googlegroups.com
Hi vims.
Well I haveaa buch of keymaos using the Shift key that works perfectly in gvim, but not in the terminal, for instance:
nnoremap <S-PageDown> v<C-D>
nnoremap <S-PageUp> v<C-U>
vnoremap <S-PageDown> <C-D>
vnoremap <S-PageUp> <C-U>
vnoremap <PageDown> <C-D>
vnoremap <PageUp> <C-U>
inoremap <S-PageDown> <Esc>v<C-D>
inoremap <S-PageUp> <Esc>v<C-U>
 or
nnoremap <S-Home> v<Home>
nnoremap <S-End> v<End>
nnoremap <C-S-Home> v<Home>
nnoremap <C-S-End> v<End>
inoremap <S-Home> <Esc>v<Home>
inoremap <S-End> <Esc>v<End>

I use these mappings to make selections using the shift key as in regular editors, but no one og them do nothing in the terminal.
The thing that is strange for me is that these other maps works:
nnoremap <C-S-Left> vb
nnoremap <C-S-Right> ve
vnoremap <C-S-Left> b
vnoremap <C-S-Right> e
inoremap <C-S-Left> <Esc><Left>vb
inoremap <C-S-Right> <Esc><Right>ve

So I guess that meybe the problem is with the PageDown/Up and Home/End keys and not with the Shift.
Any ideas????
thanks

--
Un saludo
Best Regards
Pablo Giménez

Gene Kwiecinski

unread,
Apr 28, 2009, 2:49:44 PM4/28/09
to vim...@googlegroups.com
>Well I haveaa buch of keymaos using the Shift key that works
>perfectly in gvim, but not in the terminal, for instance:

Go into insert mode and hit ^V and the key in question, for each <PgDn>
and <shf><PgDn> and see what gets returned. Might be that the g version
can discern the two, but the console version might not.

Sounds like the same complaint when people want to use, eg, ^g for one
thing, then shift it and use ^G for something else. Both ^g and ^G
"look the same", as both return the char \007 to the keyboard handler.

Gary Johnson

unread,
Apr 28, 2009, 5:48:55 PM4/28/09
to vim...@googlegroups.com
On 2009-04-28, Pablo Giménez wrote:
> Hi vims.
> Well I haveaa buch of keymaos using the Shift key that works perfectly in
> gvim, but not in the terminal, for instance:

[...]

> I use these mappings to make selections using the shift key as in regular
> editors, but no one og them do nothing in the terminal.
> The thing that is strange for me is that these other maps works:
> nnoremap <C-S-Left> vb
> nnoremap <C-S-Right> ve
> vnoremap <C-S-Left> b
> vnoremap <C-S-Right> e
> inoremap <C-S-Left> <Esc><Left>vb
> inoremap <C-S-Right> <Esc><Right>ve
>
> So I guess that meybe the problem is with the PageDown/Up and Home/End keys
> and not with the Shift.
> Any ideas????

GUI programs such as gvim receive keyboard input in the form of
keycodes, that is, some indication of which key was typed along with
any modifier keys that were being pressed at the time. Terminal
emulators also receive keyboard input in this form, but they send to
their client programs (such as vim) only 8-bit characters. Some
keys such as the arrow keys and the function keys (f1, et al.) are
indicated to the clients by sequences of 7-bit (ASCII) characters.
For example, when I press the left arrow on this keyboard, the
terminal emulator sends <esc>OD to vim, where <esc> is the ASCII
Escape character, decimal value 27.

Terminal emulators typically send unique characters or sequences of
characters beginning with the Escape character (escape sequences)
only for symbols visible on the keyboard, not for arbitrary
combinations of keys and modifiers. Notable exceptions, as you have
discovered, are the arrow keys with Shift and/or Ctrl modifiers to
allow terminal-based editors to adopt popular GUI editor paradigms.

So, you're not going to be able to use with vim in a terminal all
the mappings you can use with gvim. Which ones you can use depends
on the particular terminal emulator you're using. To find out what
character or charter sequence your terminal is emitting for a given
key, put vim into insert mode, type Ctrl-V, then type the key in
question. If Home and Shift-Home, for example, generate the same
character sequence, then vim won't be able to distinguish them.

HTH,
Gary


Pablo Giménez

unread,
Apr 29, 2009, 2:17:10 PM4/29/09
to vim...@googlegroups.com


2009/4/28 Gary Johnson <gary...@spocom.com>
Thanks Gary for he explanation, I understand.
I have checked and yes in my terminal, a xterm, is returning the same codes for both Home and Ctrl-Home, in fact any combination of Home returns always the same code.
So is there any way so setup a xterm to send to client applicatins keycodes instead of the ASCII 8bits codes???
thx


HTH,
Gary




Will

unread,
May 1, 2009, 1:00:58 PM5/1/09
to vim_use

On Apr 29, 1:17 pm, Pablo Giménez <pablog...@gmail.com> wrote:
> I have checked and yes in my terminal, a xterm, is returning the same codes
> for both Home and Ctrl-Home, in fact any combination of Home returns always
> the same code.
> So is there any way so setup a xterm to send to client applicatins keycodes
> instead of the ASCII 8bits codes???
> thx

Check for .Xresources/.Xdefaults for any keybindings/translations that
might be interfering.

Also, xterm normally captures Shift-PageUp/PageDown/Up/Down for
scrolling through the output buffer. This happens regardless of Ctrl,
Alt, Meta, or any other modifier being used in addition.

--
graywh
Reply all
Reply to author
Forward
0 new messages