How to map Alt+key when using vim in putty

894 views
Skip to first unread message

Fan Kai

unread,
Dec 18, 2008, 3:36:32 AM12/18/08
to vim_use
I can't map Alt-key in vim when open it in a putty console, with
terminal set to xterm.
I read the help of map-alt-keys, and it says it's because the terminal
would prefix the character with an ESC character.

Is there any way to solve this problem?

StarWing

unread,
Dec 18, 2008, 9:28:11 AM12/18/08
to vim_use
I have this problem, too, and i don't know how to solve, either. I use
gnome-terminal.
maybe you can try the option "esckeys", but i can't try it, i'm in
windows now.
btw, there are some problem in windows. use gvim -u N -U N, and i
can't map the <A-CR> (or <M-CR>) key, i don't know why, i can input it
with ^K. but i can't map it.

Tom Link

unread,
Dec 18, 2008, 9:54:33 AM12/18/08
to vim_use
> I can't map Alt-key in vim when open it in a putty console,  with
> terminal set to xterm.

Something like this could help:

set <m-x>=^[x

I don't know the proper help page now but the info is somewhere ... or
in the archives of this list.

See also h :map-alt-keys.

Regards,
Thomas.

Tom Link

unread,
Dec 18, 2008, 9:55:17 AM12/18/08
to vim_use
> I don't know the proper help page now but the info is somewhere

:help :set-termcap

Matt Wozniski

unread,
Dec 18, 2008, 12:14:57 PM12/18/08
to vim...@googlegroups.com
On Thu, Dec 18, 2008 at 9:54 AM, Tom Link wrote:
>
>> I can't map Alt-key in vim when open it in a putty console, with
>> terminal set to xterm.
>
> Something like this could help:
>
> set <m-x>=^[x

But note that, even in current vim, this does not work properly when
using a multibyte encoding [1].

[1] http://groups.google.com/group/vim_dev/browse_thread/thread/6c9435f656c2550c/9c7ae1b74a457306

~Matt

Marc Weber

unread,
Dec 18, 2008, 12:36:23 PM12/18/08
to vim...@googlegroups.com

If map <esc>a works instead of <m-a> I can provide a simple command
which does this substitution automatically..

So instead of
noremap you use
Noremap and that's it..

Marc Weber

Matt Wozniski

unread,
Dec 18, 2008, 12:42:51 PM12/18/08
to vim...@googlegroups.com
On Thu, Dec 18, 2008 at 12:36 PM, Marc Weber wrote:
>
> On Thu, Dec 18, 2008 at 12:36:32AM -0800, Fan Kai wrote:
>>
>> I can't map Alt-key in vim when open it in a putty console, with
>> terminal set to xterm.
>> I read the help of map-alt-keys, and it says it's because the terminal
>> would prefix the character with an ESC character.
>>
>> Is there any way to solve this problem?
>
> If map <esc>a works instead of <m-a> I can provide a simple command
> which does this substitution automatically..

Creating mappings beginning with escape is much, much less nice. The
biggest reason is that will use 'timeoutlen' instead of 'ttimeoutlen',
meaning that typing <Esc>a will often be recognized as a <M-a>
instead, unless you tweak 'timeoutlen' to be ridiculously low and deal
with all the problems caused by that.

~Matt

Reply all
Reply to author
Forward
0 new messages