How to bind <win> key?

15 views
Skip to first unread message

anhnmncb

unread,
Nov 26, 2008, 4:10:35 AM11/26/08
to vim...@googlegroups.com
As title, I don't know how to bind windows key in vim.

Teemu Likonen

unread,
Nov 26, 2008, 6:31:41 AM11/26/08
to vim...@googlegroups.com
anhnmncb (2008-11-26 09:10 +0000) wrote:

> As title, I don't know how to bind windows key in vim.

As far as I know, it's not possible.

anhnmncb

unread,
Nov 26, 2008, 9:50:06 AM11/26/08
to vim...@googlegroups.com

Hmm, so it should be a feature request :)

Tony Mechelynck

unread,
Nov 26, 2008, 10:10:12 AM11/26/08
to vim...@googlegroups.com

To see if Vim is at all able to see that you have hit the Windows key,
1) make sure you have 'showcmd' on
2) start Insert mode
3) hit Ctrl-V (or Ctrl-Q if your Ctrl-V is remapped to the "paste"
operation). You ought to see ^V (or maybe ^Q) near bottom-right of the
Vim screen.
4) hit the Windows key. If you still see ^V (or ^Q) at bottom right it
means your OS hasn't passed the Windows keypress to Vim, so there's
nothing you can bind it to as far as Vim is concerned. Otherwise you
should see the keycode newly inserted into your current edit buffer. In
that case you can use that as the {lhs} of a mapping and that mapping
will be triggered whenever you hit the Windows key in the appropriate mode.


Best regards,
Tony.
--
FIRST HEAD: All right! All right! We'll kill him first and then have tea and
biscuits.
"Monty Python and the Holy Grail" PYTHON (MONTY)
PICTURES LTD

anhnmncb

unread,
Nov 26, 2008, 10:24:19 AM11/26/08
to vim...@googlegroups.com
Tony Mechelynck (2008-11-26 16:10 +0100) wrote:

> On 26/11/08 15:50, anhnmncb wrote:
>> On 2008-11-26, Teemu Likonen wrote:
>>> anhnmncb (2008-11-26 09:10 +0000) wrote:
>>>
>>>> As title, I don't know how to bind windows key in vim.
>>> As far as I know, it's not possible.
>>
>> Hmm, so it should be a feature request :)
>
> To see if Vim is at all able to see that you have hit the Windows key,
> 1) make sure you have 'showcmd' on
> 2) start Insert mode
> 3) hit Ctrl-V (or Ctrl-Q if your Ctrl-V is remapped to the "paste"
> operation). You ought to see ^V (or maybe ^Q) near bottom-right of the
> Vim screen.
> 4) hit the Windows key. If you still see ^V (or ^Q) at bottom right it
> means your OS hasn't passed the Windows keypress to Vim, so there's
> nothing you can bind it to as far as Vim is concerned. Otherwise you
> should see the keycode newly inserted into your current edit buffer. In
> that case you can use that as the {lhs} of a mapping and that mapping
> will be triggered whenever you hit the Windows key in the appropriate mode.

<win-;> has the similar behavior with <M-;> when in insert mode here.

Yes, <win> will not pass to vim because it's bind to windows menu by OS,
I think <win-;> can pass to vim, but I don't know how to let vim know
it.

>
>
> Best regards,
> Tony.

Tim Chase

unread,
Nov 26, 2008, 10:26:38 AM11/26/08
to vim...@googlegroups.com
Tony Mechelynck wrote:
> On 26/11/08 15:50, anhnmncb wrote:
>> On 2008-11-26, Teemu Likonen wrote:
>>> anhnmncb (2008-11-26 09:10 +0000) wrote:
>>>
>>>> As title, I don't know how to bind windows key in vim.
>>> As far as I know, it's not possible.
>> Hmm, so it should be a feature request :)
>
> To see if Vim is at all able to see that you have hit the Windows key,
> 1) make sure you have 'showcmd' on
> 2) start Insert mode
> 3) hit Ctrl-V (or Ctrl-Q if your Ctrl-V is remapped to the "paste"
> operation). You ought to see ^V (or maybe ^Q) near bottom-right of the
> Vim screen.
> 4) hit the Windows key. If you still see ^V (or ^Q) at bottom right it
> means your OS hasn't passed the Windows keypress to Vim, so there's
> nothing you can bind it to as far as Vim is concerned. Otherwise you
> should see the keycode newly inserted into your current edit buffer. In
> that case you can use that as the {lhs} of a mapping and that mapping
> will be triggered whenever you hit the Windows key in the appropriate mode.

This may also depend on your environment -- In Win32, you won't
likely get anything useful (it will open the Start menu)

On *nix machines, it's so readily remappable that it relies
entirely on your configuration. I have mine set to act as Mod4
(is that "Meta" or "Super"?) and it acts as a <shift> key of
sorts, indicating that the keychord is window/desktop-control
related (win+[1-4] for "go to desktop [1-4]", win+ctrl+[1-4] for
"move the current window to desktop [1-4]", win+F12 is "toggle
window chrome", win+x is "maximize", win+t is "tile windows",
etc). Thus, Vim doesn't see it. However you can remap the "win"
key (using "xmodmap") to signal some other sort of keypress that
Vim can see and translate.

-tim


Tony Mechelynck

unread,
Nov 26, 2008, 10:33:49 AM11/26/08
to vim...@googlegroups.com

Try repeating the experiment after

:set winaltkeys=no


Best regards,
Tony.
--
You better believe that marijuana can cause castration. Just suppose
your girlfriend gets the munchies!

anhnmncb

unread,
Nov 26, 2008, 10:33:56 AM11/26/08
to vim...@googlegroups.com
Tony Mechelynck (2008-11-26 16:10 +0100) wrote:

> On 26/11/08 15:50, anhnmncb wrote:
>> On 2008-11-26, Teemu Likonen wrote:
>>> anhnmncb (2008-11-26 09:10 +0000) wrote:
>>>
>>>> As title, I don't know how to bind windows key in vim.
>>> As far as I know, it's not possible.
>>
>> Hmm, so it should be a feature request :)
>
> To see if Vim is at all able to see that you have hit the Windows key,
> 1) make sure you have 'showcmd' on
> 2) start Insert mode
> 3) hit Ctrl-V (or Ctrl-Q if your Ctrl-V is remapped to the "paste"
> operation). You ought to see ^V (or maybe ^Q) near bottom-right of the
> Vim screen.
> 4) hit the Windows key. If you still see ^V (or ^Q) at bottom right it
> means your OS hasn't passed the Windows keypress to Vim, so there's
> nothing you can bind it to as far as Vim is concerned. Otherwise you
> should see the keycode newly inserted into your current edit buffer. In
> that case you can use that as the {lhs} of a mapping and that mapping
> will be triggered whenever you hit the Windows key in the appropriate mode.

Actually, I can do it in emacs(just for an example, no war!) by:

(setq
w32-pass-lwindow-to-system nil
w32-pass-rwindow-to-system nil
w32-lwindow-modifier 'super
w32-rwindow-modifier 'super)

Then use something like <s-;>.

I don't know how to do it in vim.

anhnmncb

unread,
Nov 26, 2008, 10:37:18 AM11/26/08
to vim...@googlegroups.com

The same here, <alt-;> just produces a ``;'', so does <win-;>.

Teemu Likonen

unread,
Nov 26, 2008, 10:51:19 AM11/26/08
to vim...@googlegroups.com
Tim Chase (2008-11-26 09:26 -0600) wrote:

> On *nix machines, it's so readily remappable that it relies entirely
> on your configuration. I have mine set to act as Mod4 (is that "Meta"
> or "Super"?)

In my pretty much default (in this regard at least) KDE system the left
Windows key is Super_L, according to "xev" utility. My KDE uses it to a
couple of global desktop shortcuts (shortcut scheme: "KDE Default for 4
Modifier Keys"). Other bindings than those reserved by KDE go to
applications. Vim doesn't react to it, though, but Emacs sees it as
Super key.

John Little

unread,
Nov 26, 2008, 4:52:50 PM11/26/08
to vim_use


On Nov 26, 10:10 pm, anhnmncb wrote:
> As title, I don't know how to bind windows key in vim.

In another posting, you've said you use gvim in MS windows. If you
want to bind the 'windows', and 'menu' keys in windows XP, there are
registry keys you can set; my favourite site explaining this is

http://www.usnetizen.com/fix_capslock.html

I map them (when working in windows) to F13, F14 and F15, which then
can be mapped in Vim.

HTH, John

anhnmncb

unread,
Nov 26, 2008, 6:34:07 PM11/26/08
to vim...@googlegroups.com

Thank you, I try to not touch the evil M$ register, and I want to make a
portable gvim to prevent from touching other people's pc's register ...

Reply all
Reply to author
Forward
0 new messages