Which combination keys can be re-mapped?

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

Which combination keys can be re-mapped?

Edward L. Fox
Hi all,

The combination keys that VIM doesn't use can be easily mapped to any
customized function. Some built-in combination keys can also be re-mapped,
such as <C-V>, <C-A>, etc. But some other built-in combination keys can not be
re-mapped in normal way (at least not able to do that in my system, Fedora
Core 1, VIM 7.0 aa), such as <C-;>, <C-'>.

Is it any other way to re-map those combination keys? Or how can I know which
of the built-in shortcut keys can be re-mapped?


Regards,

Edward L. Fox
Reply | Threaded
Open this post in threaded view
|

Re: Which combination keys can be re-mapped?

A.J.Mechelynck
----- Original Message -----
From: "Edward L. Fox" <[hidden email]>
To: "Vim List" <[hidden email]>
Sent: Sunday, September 11, 2005 4:50 AM
Subject: Which combination keys can be re-mapped?


> Hi all,
>
> The combination keys that VIM doesn't use can be easily mapped to any
> customized function. Some built-in combination keys can also be re-mapped,
> such as <C-V>, <C-A>, etc. But some other built-in combination keys can
> not be
> re-mapped in normal way (at least not able to do that in my system, Fedora
> Core 1, VIM 7.0 aa), such as <C-;>, <C-'>.
>
> Is it any other way to re-map those combination keys? Or how can I know
> which
> of the built-in shortcut keys can be re-mapped?
>
>
> Regards,
>
> Edward L. Fox

Any key or key combination that Vim can recognise can be remapped. Which
keys or key combinations are recognisable may vary from one OS to the other.

Usually the following can be remapped more or less reliably:

- All printable characters
- Ctrl with a letter [A-Za-z] or with one of @[\]^_? (but with letters, Ctrl
cannot be told apart from Ctrl-Shift). Ctrl-H is the same as Bsp; Ctrl-I is
the same as Tab; Ctrl-M is the same as Enter; Ctrl-[ is the same as Esc;
Ctrl-? is (IIUC) the same as Del ("the same" in the sense that Vim cannot
tell them apart).
- All of the above with Alt; but these often cannot be told apart from
printable characters in the range 128-255. However, see also ":help
'winaltkeys'".
- The cursor movement keys (arrows, Home, End, PgUp, PgDn) with or without
some combinations of Ctrl, Shift, Alt. Which ones actually work may have to
be determined experimentally.
- F1 to F12 with or without almost any combination of Ctrl, Shift, Alt.
However, F1 is the Help key, and F10 (the Menu key) is not always remappable
unless one or more of Ctrl, Shift and Alt are used in combination with it.

IMHO the F keys (alone or with any combination of Ctrl, Shift and/or Alt)
are your best bet because Vim doesn't assign any function to them by
default.

It is also possible to remap sequences of more than one key. For instance,
when editing HTML I use the following three-key mappings:

    imap    <F12><lt><lt>    &laquo;
    imap    <F12>>>    &raquo;
    imap    <F12>oe    &#339;
    imap    <F12><Space><Space>    &nbsp;

etc.


Best regards,
Tony.


Reply | Threaded
Open this post in threaded view
|

Re: Which combination keys can be re-mapped?

Tim Chase-2
> - F1 to F12 with or without almost any combination of Ctrl, Shift, Alt.
> However, F1 is the Help key, and F10 (the Menu key) is not always
> remappable unless one or more of Ctrl, Shift and Alt are used in
> combination with it.

To add a side-note to Tony's nearly exhaustive reply :)

At least on both Win32 and Linux versions of Vim, I've
successfully remapped F1 with no problems.  I usually remap it to
ESC because on my notebook computers, it's an easy mistake to
make (I've been working on remapping my brain/fingers to use ^[
instead, but it's hard to teach an old vimmer new keyboard commands).

Additionally, on both platforms, the F10 alone will trigger the
menu...if you have it in your 'guioptions' setting.  If you don't
have the menu as one of your guioptions (likely done with

        set guioptions-=m
        set guioptions-=M

in your vimrc)

I you don't have a menu, then F10 is fair game for the remapping too.

These are my results from testing...YMMV :)

-tim






Reply | Threaded
Open this post in threaded view
|

RE: Which combination keys can be re-mapped?

Keith W. Roberts
 

> -----Original Message-----
> From: Tim Chase [mailto:[hidden email]]
> Sent: Sunday, September 11, 2005 5:31 AM
> To: Tony Mechelynck
> Cc: [hidden email]; Vim List
> Subject: Re: Which combination keys can be re-mapped?
>
> > - F1 to F12 with or without almost any combination of Ctrl,
> Shift, Alt.
> > However, F1 is the Help key, and F10 (the Menu key) is not always
> > remappable unless one or more of Ctrl, Shift and Alt are used in
> > combination with it.
>
> To add a side-note to Tony's nearly exhaustive reply :)
>
> At least on both Win32 and Linux versions of Vim, I've
> successfully remapped F1 with no problems.  I usually remap it to
> ESC because on my notebook computers, it's an easy mistake to
> make (I've been working on remapping my brain/fingers to use ^[
> instead, but it's hard to teach an old vimmer new keyboard commands).
>
> Additionally, on both platforms, the F10 alone will trigger the
> menu...if you have it in your 'guioptions' setting.  If you don't
> have the menu as one of your guioptions (likely done with
>
> set guioptions-=m
> set guioptions-=M
>
> in your vimrc)
>
> I you don't have a menu, then F10 is fair game for the remapping too.
>
> These are my results from testing...YMMV :)
>
> -tim

You can still remap F10 if you have 'm' in guioptions, by setting
winaltkeys=no and using :simalt in any maps to simulate menu options.

-Keith


Reply | Threaded
Open this post in threaded view
|

Re: Which combination keys can be re-mapped?

Tim Chase-2
> You can still remap F10 if you have 'm' in guioptions, by
> setting winaltkeys=no and using :simalt in any maps to
> simulate menu options.

Thanks for letting me know!
[files in his folder of helpful Vim tips]

I usually fly with no menu, and don't use function keys for
mappings other than when playing with example code (and for
mapping <f1> to be <esc> on several inconvenient laptops) so I
hadn't played around with this behavior a whole lot.

-tim