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

normal mappings don't always override defaults #1261

Closed
kitsu opened this issue Feb 1, 2017 · 6 comments · Fixed by #4735
Closed

normal mappings don't always override defaults #1261

kitsu opened this issue Feb 1, 2017 · 6 comments · Fixed by #4735

Comments

@kitsu
Copy link

kitsu commented Feb 1, 2017

Please thumbs-up 👍 this issue if it personally affects you! You can do this by clicking on the emoji-face on the top right of this post. Issues with more thumbs-up will be prioritized.


After adding key bindings for shift-H and shift-L the default behaviors still happen occasionally.

User settings excerpt:

    "vim.otherModesKeyBindingsNonRecursive": [
        {
            "before": ["L"],
            "after": ["$"]
        },
        {
            "before": ["H"],
            "after": ["^"]
        },
        ...other bindings...

For example just pressing L correctly moves to end of line, but pressing dL deletes until end of window/document. It works correctly in visual mode, and most of the time in normal mode, but fails almost always as a movement in a command.

I also have other bindings problems, but I think they are unrelated.

  • VSCode Version: 1.8.1
  • VsCodeVim Version: 0.5.2
  • OS: Win7
@epilande
Copy link

Any update on this issue? I'm seeing this as well when I'm in visual mode, vL should select from cursor to end of line, but instead, it selects from the cursor to end of the screen which is the default behaviour of L.

@kitsu
Copy link
Author

kitsu commented Jul 11, 2018

I just had to mess with my config again after otherModes was removed:angry:. After duplicating my bindings in both vim.normalModeKeyBindingsNonRecursive and vim.visualModeKeyBindingsNonRecursive I found that my L and H binding completely stopped working.

When I moved them to the Non-nonRecursive sections the normal mode binding started working, but only when not used in an action (i.e. L by itself moves to end of line, but dL deletes using stupid default L behavior that is useful to no one ever). Visual mode is a complete loss.

How did you implement keybind overrides but not honor them in commands? Vim bindings define a syntax. It is not reasonable to have to rebind every possible combination when a command or movement is changed!

@expelledboy
Copy link

So my thought was something along these lines

    "vim.normalModeKeyBindingsNonRecursive": [
        {
            "before": ["L"],
            "after": ["$"],
        },
        {
            "before": ["H"],
            "after": ["^"],
        },
        {
            "before": ["v", "L"],
            "after": ["v", "$"],
        },
        {
            "before": ["v", "H"],
            "after": ["v", "^"],
        },
    ],

But it doesnt work...

@AeroCross
Copy link

When I moved them to the Non-nonRecursive sections the normal mode binding started working, but only when not used in an action (i.e. L by itself moves to end of line, but dL deletes using stupid default L behavior that is useful to no one ever)

I gave this a go in vim and turns out that even there dL would do the default, so it is not necessarily VS Code Vim.

Try it out. In vim:

nnoremap L $

Then go to a line and input dL won't work as you expect. This is because d is an operator which in turn puts you in "Operator Pending Mode" which makes available a different set of bindings. Check :help omap: and go to the omap-info section for more information.

What I do find interesting is that if we go to visualModeKeyBindingsNonRecursive it should work but alas it doesn't, for some reason. The equivalent in vim would be vnoremap L $ which does work, so there's something fishy going on with Visual Mode specifically.

@expelledboy
Copy link

@AeroCross it does work in vim, your mapping is incomplete;

noremap H ^
noremap L $

@AeroCross
Copy link

AeroCross commented Jul 16, 2018

From what I can read that's because noremap means "Map to Normal, Visual, Select, and Operator Pending modes". Operator Pending mode remap isn't available to VS Code Vim.

nnoremap is only for normal mode, which is available to VS Code Vim. That would explain why that doesn't work.

@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.

5 participants