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

remappings: implement ttimeoutlen #1821

Closed
kswope opened this issue Jun 10, 2017 · 11 comments · Fixed by #4735
Closed

remappings: implement ttimeoutlen #1821

kswope opened this issue Jun 10, 2017 · 11 comments · Fixed by #4735

Comments

@kswope
Copy link

kswope commented Jun 10, 2017

  • Click thumbs-up 👍 on this issue if you want it!
  • Click confused 😕 on this issue if not having it makes VSCodeVim unusable.

The VSCodeVim team prioritizes issues based on reaction count.


Not sure if this is a bug report or a feature request

This example works

    "vim.otherModesKeyBindingsNonRecursive": [
        {
            "before": ["Z", "Z"],
            "after": [],
            "commands": [
                {
                    "command": "workbench.action.files.save",
                    "args": []
                },
                {
                    "command": "workbench.action.closeActiveEditor",
                    "args": []
                }
            ]
        }
    ]

This modification of example doesn't

    "vim.otherModesKeyBindingsNonRecursive": [
        {
            "before": ["s", "s"],
            "after": [],
            "commands": [
                {
                    "command": "workbench.action.files.save",
                    "args": []
                },
                {
                    "command": "workbench.action.closeActiveEditor",
                    "args": []
                }
            ]
        }
    ]

"s" has a special priority in vi, I know, but this behavior is inconsistent and makes me sad and go back to nvim

@Chillee
Copy link
Member

Chillee commented Jun 10, 2017

@kswope I'm confused. What do you expect to happen when you press ss? Do you expect it to simply ignore the s command?

@kswope
Copy link
Author

kswope commented Jun 11, 2017

@Chillee

That is exactly right, its not uncommon either, I think I saw it in a tutorial somewhere and got used to it, this is in my vimrc. I believe there's some kinda of timer, when I press s and wait a second it does its normal behavior, that is how jk and jj work as well, being common remappings of ESC

nnoremap ss :w" remap ss to save file

@qaraluch
Copy link

The same issue with OO and oo.

@jpoon
Copy link
Member

jpoon commented Jan 29, 2019

I mentioned here (#2932 (comment)), but we execute the first match (using the above example, we'd run s command immediately without assessing for any potential longer matches. What is vanilla vim's behaviour here?

@sobjornstad
Copy link

sobjornstad commented Jan 29, 2019

@jpoon: Basically, it waits:

  • until the sequence of keys cannot be interpreted in any other way (i.e., there are no more longer mappings) – this command is then executed
  • until the sequence of keys doesn't form any valid mapping – vim cancels the original sequence and starts a new sequence beginning with the first key that can't form a valid mapping (this behaves a little differently in insert mode, where the full sequence is then typed into the document)
  • until about one second after the last keystroke – vim executes the command associated with the keystrokes you currently have

See the various timeout options for the full scoop and ways you can customize that. Anyone else please correct me, I probably missed or misinterpreted some details.

Thanks for identifying my leader issue as related -- interesting.

@jpoon
Copy link
Member

jpoon commented Jan 31, 2019

In terms of what you defined:

until the sequence of keys cannot be interpreted in any other way (i.e., there are no more longer mappings) – this command is then executed
until the sequence of keys doesn't form any valid mapping – vim cancels the original sequence and starts a new sequence beginning with the first key that can't form a valid mapping (this behaves a little differently in insert mode, where the full sequence is then typed into the document)

vscodevim should already be aligned with the above behaviour.

until about one second after the last keystroke – vim executes the command associated with the keystrokes you currently have

Here's where our implementations differ. At the moment, on that last keystroke, we execute whatever matches instead of waiting for a longer potential remap. I'm going to re-purpose this issue to track this point.

@jpoon jpoon changed the title remapping ZZ works, ss doesn't remappings: implement ttimeoutlen Jan 31, 2019
@autolyticus
Copy link

Was about to open a new issue for a related problem when I found this one.

I encountered this same problem when I attempted to remap mm to dd to have d be the "delete" operator and m be the "cut" operator. As a result of this, we cannot have a working mapping for mm or m* as long as the mapping for m exists.

@mauricecruz
Copy link

Recently migrated from Atom using vim-mode-plus. I remapped jj to <Esc> and noticed that a j always prints out first before getting removed and the mode changing.

Here's where our implementations differ. At the moment, on that last keystroke, we execute whatever matches instead of waiting for a longer potential remap. I'm going to re-purpose this issue to track this point.

That seems like a plausible explanation of what I'm experiencing. Is that what's going on or is there some type of configuration I'm missing?

@jpoon
Copy link
Member

jpoon commented Nov 15, 2019

Nope, that would explain your experience with the momentary "j"

@mauricecruz
Copy link

mauricecruz commented Nov 19, 2019

What's the likelihood of this getting implemented in the short term?

I've noticed an increase in typos because of dangling j's in my code because the print out is included in the history buffer.

So when I undo something, I have to undo twice to get to the right undo position.

@istrupin
Copy link

istrupin commented Apr 2, 2020

The same issue with OO and oo.

Seeing the same behavior here -- wanted to remap those to insert a new line and go back to normal mode, but no such luck.

berknam pushed a commit to berknam/Vim that referenced this issue Apr 13, 2020
Refactor the Remapper and ModeHandler to allow better remapping experience.
It will allow to remap operator keys, motion keys and multiple keys when the first key could be handled.

Should fix the following issues (maybe more):
VSCodeVim#4674
VSCodeVim#4464
VSCodeVim#3988
VSCodeVim#3768
VSCodeVim#3742
VSCodeVim#2975
VSCodeVim#2955
VSCodeVim#2234
VSCodeVim#2041
VSCodeVim#1870
VSCodeVim#1821
VSCodeVim#1579
VSCodeVim#1398

Needs more testing.
@berknam berknam mentioned this issue Apr 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.

8 participants