f



VIM: "map! <ESC> <ESC>:wq<ENTER>" turns my arrows keys into <ESC>

Anyone know why this map

  map! <ESC> <ESC>:wq<ENTER>

makes my arrow keys behave like the escape key?

After this map whenever I touch any of my arrow keys 
it writes the file and quits vim - as if I'd hit 
the <ESC> key with that map.  Even the <ESC> key
itself doesn't work as advertised because I have
to hit it twice to get it to execute the map, 
whereas the arrow keys kick in the map at first 
touch.

Ian
0
Ian
9/17/2003 1:37:04 AM
comp.editors 4871 articles. 0 followers. Post Follow

3 Replies
842 Views

Similar Articles

[PageSpeed] 6

Ian Gil <i@NOSPAMALLOWED.com> wrote:
>
>Anyone know why this map
>
>  map! <ESC> <ESC>:wq<ENTER>
>
>makes my arrow keys behave like the escape key?
>
>After this map whenever I touch any of my arrow keys 
>it writes the file and quits vim - as if I'd hit 
>the <ESC> key with that map.  Even the <ESC> key
>itself doesn't work as advertised because I have
>to hit it twice to get it to execute the map, 
>whereas the arrow keys kick in the map at first 
>touch.

Is this on Linux?  The function keys in an xterm session are usually
implemented as VT-100-style escape sequences (esc [ A, for example).
Because of that, it can't tell that you really meant "escape" until it sees
the second keystroke.

Escape is one of the keys that you should never redefine.
-- 
- Tim Roberts, timr@probo.com
  Providenza & Boekelheide, Inc.
0
Tim
9/17/2003 5:15:38 AM
>> Anyone know why this map
> 
>>   map! <ESC> <ESC>:wq<ENTER>
> 
>> makes my arrow keys behave like the escape key?
> 
> Please see the recent "Why vim is slower than gvim" thread.
> 
> Peppe   [very related stuff for teminals discussed there]

Ok. Are the arrows the only way to get the cursor to move?  I tried to
remap the left-arrow to "<ESC>hi" but that didn't seem to work.

Thanks,

Ian
0
Ian
10/6/2003 1:16:15 AM
On 2003-10-06, Ian Gil <i@NOSPAMALLOWED.com> wrote:
>>> Anyone know why this map
>> 
>>>   map! <ESC> <ESC>:wq<ENTER>
>> 
>>> makes my arrow keys behave like the escape key?
>> 
>> Please see the recent "Why vim is slower than gvim" thread.
>> 
>> Peppe   [very related stuff for teminals discussed there]
>
> Ok. Are the arrows the only way to get the cursor to move?  I tried to
> remap the left-arrow to "<ESC>hi" but that didn't seem to work.

Of course it won't work :) You missed the point. If you set noesckeys
then your arrow keys won't be recognized at all in vim (not gvim). So
any mappings asigned to them won't be recognized as well. One possible
way around this problem is to map key-sequence generated by you arrow
key. For example 

map! [A ki

So when you hit an arrow key the first <ESC> will put you into command
mode, then the rest of arrow-key code would move your cursor in desired
position and then enter insert mode again.

This is just an idea. I didn't try it. (To see which sequence of bytes
is sent for each of arrow keys I use showkey program)

--
Andrei


0
Andrei
10/6/2003 1:40:54 PM
Reply: