Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

<space> key cannot be used to map unless it is the <leader> #4236

Closed
Shane-XB-Qian opened this issue Nov 2, 2019 · 10 comments · Fixed by #4735
Closed

<space> key cannot be used to map unless it is the <leader> #4236

Shane-XB-Qian opened this issue Nov 2, 2019 · 10 comments · Fixed by #4735

Comments

@Shane-XB-Qian
Copy link

Shane-XB-Qian commented Nov 2, 2019

Describe the bug
looks key can not mapped to

To Reproduce
e.g. key mapping to 'exit' :

        { 
            "before": ["<space>", "q"], 
            "after": [],
            "commands": [
                {
                    "command": "exit", 
                    "args": []
                }
            ] 
        },

// not sure the 'exit' command was, here just assume it is 'exit'.

Expected behavior
vsc exit.

Screenshots
n/a

Environment (please complete the following information):
vsc: 1.39.2
vim in vsc: 1.11.3
ubuntu 18.04

Additional context
n/a

@Shane-XB-Qian
Copy link
Author

Shane-XB-Qian commented Nov 2, 2019

looks it just allowed change the leader key to <space>, but not allow just using the <space> as the direct hotkey ?

@Shane-XB-Qian Shane-XB-Qian changed the title <space> key can not be mapped ? <space> key can not used to map ? Nov 2, 2019
@Shane-XB-Qian Shane-XB-Qian changed the title <space> key can not used to map ? <space> key can not be used to map ? Nov 2, 2019
@sql-koala
Copy link
Contributor

Hi, there is no problem with mapping space. You can do this for example:

{
            "before": ["<space>", "q"],
            "commands": ["workbench.action.closeActiveEditor"]            
        },

But I could not find a command to exit vscode; maybe there is no command to do that.

@Shane-XB-Qian
Copy link
Author

Hi, there is no problem with mapping space. You can do this for example:

{
            "before": ["<space>", "q"],
            "commands": ["workbench.action.closeActiveEditor"]            
        },

But I could not find a command to exit vscode; maybe there is no command to do that.

you modified the leader key to <space> ?
otherwise, i do not think so - that would not work ..

@J-Fields
Copy link
Member

J-Fields commented Nov 2, 2019

I believe this is a duplicate of #2249

@Shane-XB-Qian
Copy link
Author

I believe this is a duplicate of #2249

not sure if it was a duplicate of that ticket ..
in the 'real' vim, it can map a key (e.g. <space>) but did not say it had to be a 'leader' key first ..
but here - vim in vsc, looks it had to be, but if so, the leader key changed which i did not expect that ..

@J-Fields
Copy link
Member

J-Fields commented Nov 2, 2019

You're right, I misread. We do support mapping space though - try this:

{ "before": ["<space>", "n"], "commands": [":q"] },

@Shane-XB-Qian
Copy link
Author

no, looks did not work.
looks <space> was a special key in vim-in-vsc, unless as that ticket said - only if it supported there were some 'leader-key' can be defined ..

@sql-koala
Copy link
Contributor

sql-koala commented Nov 2, 2019

Hi again,
the thing is: <space> has a function in normal vim: move cursor right.
This is also implemented in vscodevim and that why this mapping only works with a leader. Then, vscodevim waits for the second key.
So you can do (with space as leader):

{
            "before": ["<space>", "q"],
            "commands": ["workbench.action.closeActiveEditor"]            
        },

or

{
            "before": ["<space>"],
            "commands": ["workbench.action.closeActiveEditor"]            
        },

@Shane-XB-Qian
Copy link
Author

yes, but i do not believe someone would really use <space> to move cursor right in normal vim. -_-#
anyway, in the normal vim, <space> did not have to be a 'leader' key.
so now, the problem here vim-in-vsc, how to make it work without set <space> as leader key ?

@Shane-XB-Qian
Copy link
Author

your second option (just a <space>) - it works. but looks that's a bad mapping, single key to close a editor - looks had some risk ...

@J-Fields J-Fields changed the title <space> key can not be used to map ? <space> key cannot be used to map unless it is the <leader> Nov 18, 2019
@berknam berknam mentioned this issue May 13, 2020
10 tasks
J-Fields pushed a commit that referenced this issue Aug 16, 2020
This is a pretty massive change; see pull request #4735 for full details

Most notably:
- Support for operator-pending mode, including remaps and a half-cursor decoration
- Correct handling of ambiguous remaps with timeout
- Correct handling of recursive special case when the RHS starts with the LHS
- Correct handling of multi-key remaps in insert mode
- Failed movements that occur partway through a remap stop & discard the rest of the remap
- Implement `unmap` and `mapclear` in .vimrc

Refs #463, refs #4908
Fixes #1261, fixes #1398, fixes #1579, fixes #1821, fixes #1835
Fixes #1870, fixes #1883, fixes #2041, fixes #2234, fixes #2466
Fixes #2897, fixes #2955, fixes #2975, fixes #3082, fixes #3086
Fixes #3171, fixes #3373, fixes #3413, fixes #3742, fixes #3768
Fixes #3988, fixes #4057, fixes #4118, fixes #4236, fixes #4353
Fixes #4464, fixes #4530, fixes #4532, fixes #4563, fixes #4674
Fixes #4756, fixes #4883, fixes #4928, fixes #4991, fixes #5016
Fixes #5057, fixes #5067, fixes #5084, fixes #5125
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants