strange problem with <End>, <Home> key mapping

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

strange problem with <End>, <Home> key mapping

Weronika Patena
Hi!

I'm trying to get my End and Home keys to behave like g$ and g^, i.e. to go to the
end/beginning of the current screen line, not the full line, which is longer.
I'd like this behavior to work in both insert and command mode.

Here are my keybindings, in the .vimrc file:

map <End> g$
imap <End> <c-o>g$
map <Home> g^
imap <Home> <c-o>g^

The result - it works fine in insert mode, but for some reason doesn't in command mode.  
Moreover, if I add this binding: "map , <End>", it causes the "," key to behave like g$,
so it seems like my mappings are getting trasmitted down, but they're still not working
with the actual End key!  Any idea why this would be happening?

I have a corresponding mapping for the Up/Down keys, which works fine in both modes:

map <up> gk
imap <up> <c-o>gk
map <down> gj
imap <down> <c-o>gj

Weronika

--
Weronika Patena
Stanford, CA, USA
http://vole.stanford.edu/weronika
Reply | Threaded
Open this post in threaded view
|

Re: strange problem with <End>, <Home> key mapping

A.J.Mechelynck
----- Original Message -----
From: "Weronika Patena" <[hidden email]>
To: <[hidden email]>
Sent: Thursday, August 11, 2005 12:05 AM
Subject: strange problem with <End>, <Home> key mapping


> Hi!
>
> I'm trying to get my End and Home keys to behave like g$ and g^, i.e. to
> go to the
> end/beginning of the current screen line, not the full line, which is
> longer.
> I'd like this behavior to work in both insert and command mode.
>
> Here are my keybindings, in the .vimrc file:
>
> map <End> g$
> imap <End> <c-o>g$
> map <Home> g^
> imap <Home> <c-o>g^
>
> The result - it works fine in insert mode, but for some reason doesn't in
> command mode.
> Moreover, if I add this binding: "map , <End>", it causes the "," key to
> behave like g$,
> so it seems like my mappings are getting trasmitted down, but they're
> still not working
> with the actual End key!  Any idea why this would be happening?
>
> I have a corresponding mapping for the Up/Down keys, which works fine in
> both modes:
>
> map <up> gk
> imap <up> <c-o>gk
> map <down> gj
> imap <down> <c-o>gj
>
> Weronika
>
> --
> Weronika Patena
> Stanford, CA, USA
> http://vole.stanford.edu/weronika

Works for me.

If you have Normal-mode mappings on g^ and g$ (or on ^ and $) you might want
to use non-recursive mappings, e.g.

    noremap    <Home>    g^
    noremap    <End>    g$

Also, g^ and g$ are indistinguishable from the default behaviour of <Home>
and <End> when 'wrap' is off.

HTH,
Tony.


Reply | Threaded
Open this post in threaded view
|

Re: strange problem with <End>, <Home> key mapping

Weronika Patena
On Thu, Aug 11, 2005 at 12:49:46AM +0200, Tony Mechelynck wrote:

> ----- Original Message -----
> From: "Weronika Patena" <[hidden email]>
> >Here are my keybindings, in the .vimrc file:
> >
> >map <End> g$
> >imap <End> <c-o>g$
> >map <Home> g^
> >imap <Home> <c-o>g^
> >
> >The result - it works fine in insert mode, but for some reason doesn't in
> >command mode.  Moreover, if I add this binding: "map , <End>", it causes
> >the "," key to behave like g$, so it seems like my mappings are getting
> >trasmitted down, but they're still not working with the actual End key!  
> >Any idea why this would be happening?
>
> Works for me.
>
> If you have Normal-mode mappings on g^ and g$ (or on ^ and $) you might
> want to use non-recursive mappings, e.g.
>
>    noremap    <Home>    g^
>    noremap    <End>    g$

These are my only mappings.  Just in case, I'll copy my whole .vimrc file - maybe one of the options is interfering?

set nocompatible
set bs=2
set ts=4
set ruler
set noautoindent
set nocindent
set expandtab
map <up> gk
imap <up> <c-o>gk
map <down> gj
imap <down> <c-o>gj
map <End> g$
imap <End> <c-o>g$
map <Home> g^
imap <Home> <c-o>g^

That's everything.

> Also, g^ and g$ are indistinguishable from the default behaviour of <Home>
> and <End> when 'wrap' is off.

Right.  But I want 'wrap' to stay on.

Weronika

--
Weronika Patena
Stanford, CA, USA
http://vole.stanford.edu/weronika
Reply | Threaded
Open this post in threaded view
|

Re: strange problem with <End>, <Home> key mapping

A.J.Mechelynck
----- Original Message -----
From: "Weronika Patena" <[hidden email]>
To: "Tony Mechelynck" <[hidden email]>
Cc: <[hidden email]>
Sent: Thursday, August 11, 2005 2:54 AM
Subject: Re: strange problem with <End>, <Home> key mapping


> On Thu, Aug 11, 2005 at 12:49:46AM +0200, Tony Mechelynck wrote:
>> ----- Original Message -----
>> From: "Weronika Patena" <[hidden email]>
>> >Here are my keybindings, in the .vimrc file:
>> >
>> >map <End> g$
>> >imap <End> <c-o>g$
>> >map <Home> g^
>> >imap <Home> <c-o>g^
>> >
>> >The result - it works fine in insert mode, but for some reason doesn't
>> >in
>> >command mode.  Moreover, if I add this binding: "map , <End>", it causes
>> >the "," key to behave like g$, so it seems like my mappings are getting
>> >trasmitted down, but they're still not working with the actual End key!
>> >Any idea why this would be happening?
>>
>> Works for me.
>>
>> If you have Normal-mode mappings on g^ and g$ (or on ^ and $) you might
>> want to use non-recursive mappings, e.g.
>>
>>    noremap    <Home>    g^
>>    noremap    <End>    g$
>
> These are my only mappings.  Just in case, I'll copy my whole .vimrc
> file - maybe one of the options is interfering?
>
> set nocompatible
> set bs=2
> set ts=4
> set ruler
> set noautoindent
> set nocindent
> set expandtab
> map <up> gk
> imap <up> <c-o>gk
> map <down> gj
> imap <down> <c-o>gj
> map <End> g$
> imap <End> <c-o>g$
> map <Home> g^
> imap <Home> <c-o>g^
>
> That's everything.

I don't see anything wrong with that. And you say <Up> and <Down> work as
mapped (up and down by screen lines, even on wrapped text)? In what way are
the "horizontal" mappings not working? -- And BTW, what I wrote below is
slightly inexact: g^ is to the first nonblank, going to the first (blank or
not) is g0 or g<Home>.

Are you sure no mappings are defined by plugins? (":map" and ":map!" with no
arguments would show all mappings, and ":scriptnames" all scripts sourced)

If the above doesn't help you, I don't know what would.

>
>> Also, g^ and g$ are indistinguishable from the default behaviour of
>> <Home>
>> and <End> when 'wrap' is off.
>
> Right.  But I want 'wrap' to stay on.
>
> Weronika
>
> --
> Weronika Patena
> Stanford, CA, USA
> http://vole.stanford.edu/weronika



Best regards,
Tony.


Reply | Threaded
Open this post in threaded view
|

Re: strange problem with <End>, <Home> key mapping

Weronika Patena
On Thu, Aug 11, 2005 at 03:24:21AM +0200, Tony Mechelynck wrote:

> ----- Original Message -----
> From: "Weronika Patena" <[hidden email]>
> To: "Tony Mechelynck" <[hidden email]>
> Cc: <[hidden email]>
> Sent: Thursday, August 11, 2005 2:54 AM
> Subject: Re: strange problem with <End>, <Home> key mapping
>
>
> >On Thu, Aug 11, 2005 at 12:49:46AM +0200, Tony Mechelynck wrote:
> >>----- Original Message -----
> >>From: "Weronika Patena" <[hidden email]>
> >>>Here are my keybindings, in the .vimrc file:
> >>>
> >>>map <End> g$
> >>>imap <End> <c-o>g$
> >>>map <Home> g^
> >>>imap <Home> <c-o>g^
> >>>
> >>>The result - it works fine in insert mode, but for some reason doesn't
> >>>in
> >>>command mode.  Moreover, if I add this binding: "map , <End>", it causes
> >>>the "," key to behave like g$, so it seems like my mappings are getting
> >>>trasmitted down, but they're still not working with the actual End key!
> >>>Any idea why this would be happening?
> >
> >These are my only mappings.  Just in case, I'll copy my whole .vimrc
> >file - maybe one of the options is interfering?
>
> I don't see anything wrong with that. And you say <Up> and <Down> work as
> mapped (up and down by screen lines, even on wrapped text)? In what way are
> the "horizontal" mappings not working?

Up and Down work the way they should (i.e. go up/down by one screen line) in both modes.  
In Insert mode, Home/End work, i.e. go to the start/end of the screen line, but in normal
mode Home/End do the same thing they used to do before the mapping, i.e. go to the start/end
of the whole line, wrapped across many screen lines.

> Are you sure no mappings are defined by plugins? (":map" and ":map!" with
> no arguments would show all mappings, and ":scriptnames" all scripts
> sourced)

Hmm.  There seem to be some mappings defined in /etc/vimrc - here are the ones that involve End or Home:
    map! <Esc>[H  <Home>
    map! <Esc>[F  <End>
    map! <Esc>[1~ <Home>
    map! <Esc>[4~ <End>
    map! <Esc>OH <Home>
    map! <Esc>OF <End>
    map! <ESC>O2H <Home>
    map! <ESC>O2F <End>
    map! <ESC>O5H <Home>
    map! <ESC>O5F <End>

The same mappings appear in :map.  In addition to those, both :map and :map! show:
   <xHome>       <Home>
   <xEnd>        <End>

Does any of this seem like it could create a problem?

I did try using <xEnd> and <xHome> instead of <End> and <Home> in my mappings, but then they just didn't
work in either mode.

> If the above doesn't help you, I don't know what would.

This is pretty confusing.  Thanks for the help!

Weronika

--
Weronika Patena
Stanford, CA, USA
http://vole.stanford.edu/weronika
Reply | Threaded
Open this post in threaded view
|

Re: strange problem with <End>, <Home> key mapping

A.J.Mechelynck
----- Original Message -----
From: "Weronika Patena" <[hidden email]>
To: "Tony Mechelynck" <[hidden email]>
Cc: <[hidden email]>
Sent: Thursday, August 11, 2005 3:37 AM
Subject: Re: strange problem with <End>, <Home> key mapping


> On Thu, Aug 11, 2005 at 03:24:21AM +0200, Tony Mechelynck wrote:
>> ----- Original Message -----
>> From: "Weronika Patena" <[hidden email]>
>> To: "Tony Mechelynck" <[hidden email]>
>> Cc: <[hidden email]>
>> Sent: Thursday, August 11, 2005 2:54 AM
>> Subject: Re: strange problem with <End>, <Home> key mapping
>>
>>
>> >On Thu, Aug 11, 2005 at 12:49:46AM +0200, Tony Mechelynck wrote:
>> >>----- Original Message -----
>> >>From: "Weronika Patena" <[hidden email]>
>> >>>Here are my keybindings, in the .vimrc file:
>> >>>
>> >>>map <End> g$
>> >>>imap <End> <c-o>g$
>> >>>map <Home> g^
>> >>>imap <Home> <c-o>g^
>> >>>
>> >>>The result - it works fine in insert mode, but for some reason doesn't
>> >>>in
>> >>>command mode.  Moreover, if I add this binding: "map , <End>", it
>> >>>causes
>> >>>the "," key to behave like g$, so it seems like my mappings are
>> >>>getting
>> >>>trasmitted down, but they're still not working with the actual End
>> >>>key!
>> >>>Any idea why this would be happening?
>> >
>> >These are my only mappings.  Just in case, I'll copy my whole .vimrc
>> >file - maybe one of the options is interfering?
>>
>> I don't see anything wrong with that. And you say <Up> and <Down> work as
>> mapped (up and down by screen lines, even on wrapped text)? In what way
>> are
>> the "horizontal" mappings not working?
>
> Up and Down work the way they should (i.e. go up/down by one screen line)
> in both modes.
> In Insert mode, Home/End work, i.e. go to the start/end of the screen
> line, but in normal
> mode Home/End do the same thing they used to do before the mapping, i.e.
> go to the start/end
> of the whole line, wrapped across many screen lines.
>
>> Are you sure no mappings are defined by plugins? (":map" and ":map!" with
>> no arguments would show all mappings, and ":scriptnames" all scripts
>> sourced)
>
> Hmm.  There seem to be some mappings defined in /etc/vimrc - here are the
> ones that involve End or Home:
>    map! <Esc>[H  <Home>
>    map! <Esc>[F  <End>
>    map! <Esc>[1~ <Home>
>    map! <Esc>[4~ <End>
>    map! <Esc>OH <Home>
>    map! <Esc>OF <End>
>    map! <ESC>O2H <Home>
>    map! <ESC>O2F <End>
>    map! <ESC>O5H <Home>
>    map! <ESC>O5F <End>

These look like terminal keycodes. With exclamation marks they affect
Insert- and Command-line mode, the same without the ! would affect Normal
and Visual.

>
> The same mappings appear in :map.  In addition to those, both :map and
> :map! show:
>   <xHome>       <Home>
>   <xEnd>        <End>

These are for the keyboards where the "grey" Home and End send a different
code than the "numeric keypad" Home and End do in non-NumLock mode. They are
standard.

>
> Does any of this seem like it could create a problem?
>
> I did try using <xEnd> and <xHome> instead of <End> and <Home> in my
> mappings, but then they just didn't
> work in either mode.

Try mapping them to g<Home> and g<End> instead of g^ and g$; or try using
":noremap" instead of ":map". If that works, then maybe one or more of g ^ $
has been remapped. You might try redirecting the output of ":map" to a
register to examine it at your leisure in a Vim buffer, as follows:

    :set nomore
    :redir @"
    :map
    :map!
    :redir END
    :set more
    :new
    :0put

>
>> If the above doesn't help you, I don't know what would.
>
> This is pretty confusing.  Thanks for the help!
>
> Weronika
>
> --
> Weronika Patena
> Stanford, CA, USA
> http://vole.stanford.edu/weronika
>
>

Best regards,
Tony.


Reply | Threaded
Open this post in threaded view
|

Re: strange problem with <End>, <Home> key mapping

Weronika Patena
On Thu, Aug 11, 2005 at 04:04:30AM +0200, Tony Mechelynck wrote:
> Try mapping them to g<Home> and g<End> instead of g^ and g$; or try using
> ":noremap" instead of ":map". If that works, then maybe one or more of g ^
> $ has been remapped.

No change.  In fact, I can't map <End> and <Home> in normal mode to anything...
Or, to be more exact: I can't map them to <Up> or <Down>, or to x (i.e. delete
character), or to cw, r, a, o, ... (I think I don't need to try anything more).

OK, now I'm really confused.  I tried mapping <End> to i, and played around with it some more.  
Further results - actually, all the mappings of <End> work if they occur after an Esc.  It doesn't matter
whether the Esc happens in normal or insert mode - in either case when I press End right after Esc,
my mapping works, and otherwise it doesn't.  Of course, there may be some additional weirdness
I haven't found yet...

Does anyone have any idea what's going on???

Mappings of <End> and <Home> in insert mode work fine.  
I'm using noremap and imap, in case it matters.

Thanks,
Weronika

--
Weronika Patena
Stanford, CA, USA
http://vole.stanford.edu/weronika
Reply | Threaded
Open this post in threaded view
|

Re: strange problem with <End>, <Home> key mapping

A.J.Mechelynck
----- Original Message -----
From: "Weronika Patena" <[hidden email]>
To: "Tony Mechelynck" <[hidden email]>
Cc: <[hidden email]>
Sent: Friday, August 19, 2005 4:13 AM
Subject: Re: strange problem with <End>, <Home> key mapping


> On Thu, Aug 11, 2005 at 04:04:30AM +0200, Tony Mechelynck wrote:
>> Try mapping them to g<Home> and g<End> instead of g^ and g$; or try using
>> ":noremap" instead of ":map". If that works, then maybe one or more of g
>> ^
>> $ has been remapped.
>
> No change.  In fact, I can't map <End> and <Home> in normal mode to
> anything...
> Or, to be more exact: I can't map them to <Up> or <Down>, or to x (i.e.
> delete
> character), or to cw, r, a, o, ... (I think I don't need to try anything
> more).
>
> OK, now I'm really confused.  I tried mapping <End> to i, and played
> around with it some more.
> Further results - actually, all the mappings of <End> work if they occur
> after an Esc.  It doesn't matter
> whether the Esc happens in normal or insert mode - in either case when I
> press End right after Esc,
> my mapping works, and otherwise it doesn't.  Of course, there may be some
> additional weirdness
> I haven't found yet...
>
> Does anyone have any idea what's going on???
>
> Mappings of <End> and <Home> in insert mode work fine.
> I'm using noremap and imap, in case it matters.
>
> Thanks,
> Weronika
>
> --
> Weronika Patena
> Stanford, CA, USA
> http://vole.stanford.edu/weronika

I'm not sure. It might have something to do with what your keyboard is
sending for these "special" keys.

Try playing with the settings for 'timeout', 'timeoutlen', 'ttimeout' and
'ttimeoutlen' after reading the corresponding help.


Best regards,
Tony.