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

Mapping ciw to cw does not work as expected #2975

Closed
tom-rb opened this issue Aug 21, 2018 · 5 comments · Fixed by #4735
Closed

Mapping ciw to cw does not work as expected #2975

tom-rb opened this issue Aug 21, 2018 · 5 comments · Fixed by #4735

Comments

@tom-rb
Copy link

tom-rb commented Aug 21, 2018

Description

Basically I want:

"vim.normalModeKeyBindingsNonRecursive": [
        {
            "before": ["c","w"],
            "after": ["c", "i", "w"]
        },
        {
            "before": ["v","w"],
            "after": ["v", "i", "w"]
        },
]

What happens is that, after pressing cw, the sequence of keys sent is cciw and I end up with a whole line being changed (cc) and then the characters iw are inserted.

After pressing vw it just ignores mapping and behave as vw instead of the desired viw.

To Reproduce
Steps to reproduce the behavior:

  1. Configure the mapping as indicated in the description above
  2. In normal mode, trigger cw
  3. See error: whole line substituted by iw.

Expected behavior
After pressing cw I expected that only the word under cursor is deleted and insert mode is activated.

Environment

  • Extension Name: vim
  • Extension Version: 0.16.0
  • OS Version: Linux x64 4.4.0-133-generic
  • VSCode version: 1.26.1

Workaround

By using the following mapping I can get the expected behavior for cw:

"vim.normalModeKeyBindingsNonRecursive": [
        {
            "before": ["c","w"],
            "after": ["i", "w"]
        },
]

I can't use the same workaround for mapping vw to viw.

@jpoon
Copy link
Member

jpoon commented Aug 24, 2018

What's the output when trying https://github.com/VSCodeVim/Vim#debugging-remappings?

@tom-rb
Copy link
Author

tom-rb commented Aug 27, 2018

For config "vim.normalModeKeyBindingsNonRecursive": [ { "before": ["c","w"], "after": ["c", "i", "w"] } ]:

console.ts:136 [Extension Host] debug: ModeHandler: handling key=c.
console.ts:136 [Extension Host] debug: Remapper: normalModeKeyBindingsNonRecursive. before=c,w. after=c,i,w. 
console.ts:136 [Extension Host] debug: ModeHandler: handling key=w.
console.ts:136 [Extension Host] debug: Remapper: normalModeKeyBindingsNonRecursive. before=c,w. after=c,i,w. 
console.ts:136 [Extension Host] debug: Remapper: normalModeKeyBindingsNonRecursive. match found. before=c,w. after=c,i,w. command=undefined.
console.ts:136 [Extension Host] debug: ModeHandler: handling key=c.
console.ts:136 [Extension Host] debug: ModeHandler: handling key=i.
console.ts:136 [Extension Host] debug: ModeHandler: handling key=w.

And for vw -> viw

console.ts:136 [Extension Host] debug: ModeHandler: handling key=v.
console.ts:136 [Extension Host] debug: Remapper: normalModeKeyBindingsNonRecursive. before=v,w. after=v,i,w. 
console.ts:136 [Extension Host] debug: onDidChangeConfiguration: reloading configuration
console.ts:136 [Extension Host] debug: ModeHandler: handling key=w.

@Spirarel
Copy link

Did you find a resolution to this problem? I'm facing something similar.

@tom-rb
Copy link
Author

tom-rb commented Oct 17, 2018

Besides the workaround I've mentioned, nope.

@Spirarel
Copy link

Bummer. Thanks anyway

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.

3 participants