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

vim: Add sneak motion #22793

Merged
merged 9 commits into from
Jan 10, 2025
Merged

Conversation

nilehmann
Copy link
Contributor

@nilehmann nilehmann commented Jan 7, 2025

A (re)continuation of #21067.

This takes the original implementation in #15572 and adds the test in #21067. Then, as requested in #21067 (comment), it documents how to map a keybinding instead of having a setting.

Closes #13858

Release Notes:

  • Added support for the popular vim_sneak plugin. This is disabled by default and can be enabled by binding a key to the Sneak and SneakBackward operators.

Reference:
https://github.com/justinmk/vim-sneak

mrkajetanp and others added 4 commits January 7, 2025 16:33
Implement support for the vim sneak motion from the vim-sneak plugin.
The motion jumps forward or backward to any location specified by two
characters.

The Sneak & SneakBackward operators are bound to 'z' and 'Z' by default
to avoid overwriting the 's' and 'S' default keybindings, similar to the
way the original plugin uses 'z' with operators to avoid conflicts.

Reference:
https://github.com/justinmk/vim-sneak
Copy link

cla-bot bot commented Jan 7, 2025

We require contributors to sign our Contributor License Agreement, and we don't have @nilehmann on file. You can sign our CLA at https://zed.dev/cla. Once you've signed, post a comment here that says '@cla-bot check'.

@nilehmann
Copy link
Contributor Author

@cla-bot check

@cla-bot cla-bot bot added the cla-signed The user has signed the Contributor License Agreement label Jan 7, 2025
Copy link

cla-bot bot commented Jan 7, 2025

The cla-bot has been summoned, and re-checked this pull request!

@maxdeviant maxdeviant changed the title vim: Add sneak motion (re-continued) vim: Add sneak motion Jan 9, 2025
@ConradIrwin ConradIrwin enabled auto-merge January 10, 2025 06:46
@ConradIrwin
Copy link
Member

@nilehmann Thanks for taking the time to clean this up! I pushed a few minor tweaks, and will merge when green

@ConradIrwin ConradIrwin added this pull request to the merge queue Jan 10, 2025
Merged via the queue into zed-industries:main with commit 0b105ba Jan 10, 2025
14 checks passed
@nilehmann nilehmann deleted the push-ttnnvmvyxppy branch January 10, 2025 10:18
@jmagaram
Copy link

How do I use this? I'm on 168.3 but can't find/see any sneak option in the default vim keymap.

@ConradIrwin
Copy link
Member

@jmagaram This will first appear in 0.170 (which will likely go to preview on Wednesday, and stable one week later).

@cwooldridge1
Copy link

Thanks for adding this feature, maybe my understanding of "smartcase" being set to true is wrong but if smart case is set to true and I type s ca shouldnt that jump to the word Cat e.g. ignoring the casing difference? As right now it does not ignoring the casing difference.

@nilehmann
Copy link
Contributor Author

nilehmann commented Jan 16, 2025

Your understanding is correct and that's the behavior I'm seeing. Do you have {"vim": {"use_smartcase_find": true}} in settings.json?

@cwooldridge1
Copy link

{"vim": {"use_smartcase_find": tru

I did not have this, thank you, it works now.

@cwooldridge1
Copy link

Is there a plan to add streak mode for this? If streak mode existed the demand for something like easymotion would be limitted.

@ConradIrwin
Copy link
Member

No plans, but if you want to help implement it I'd happily pair: https://calendly.com/conradirwin/pairing

@styx styx mentioned this pull request Jan 22, 2025
1 task
@ChzenChzen
Copy link

ChzenChzen commented Jan 23, 2025

Hello! I am newbie in vim mode, I already have s key in vim for delete char and switch to insert mode.
I enabled sneakpeak mode, but when I try to press s key, I will get default s key behavior for vim mode.

"vim": {
        "enable_vim_sneak": true,
        "use_system_clipboard": "never"
    }

Maybe I need to set up keybinds, but I don't know good solution for that )).
Could you share your settings and keybinds for this feature. Thanks!


update: I tried to set up the next:

    {
        "context": "Editor && vim_mode == visual && !VimWaiting && !VimObject",
        "bindings": {
            "s": "vim::Sneak",
            "S": "vim::SneakBackward"
        }
    },

but it does change nothing.

@dream-dasher
Copy link

dream-dasher commented Jan 23, 2025

@ChzenChzen

[
  {
    "context": "vim_mode == normal || vim_mode == visual",
    "bindings": {
      "s": ["vim::PushOperator", { "Sneak": {} }],
      "S": ["vim::PushOperator", { "SneakBackward": {} }]
    }
  }
]

Per here

If that's not working you've, and you're editing the correct document, then you've likely either (a) got a syntax break somewhere, which will retain previous keybinds and just not update (can be confusing) or (b) have competing keybinds somewhere (you can try "s/"S/shift-s and look about)

@machin3io
Copy link

machin3io commented Jan 23, 2025

Thank you for this, after the recent Easymotion implementation was turned down, having this now is the next best thing :) Working great, except that ctrl-o does not seem to return to the starting point?

@fourcolors
Copy link

Thank you for making this!

@fourcolors
Copy link

How do I enable the highlighting?

@ConradIrwin
Copy link
Member

Highlighting is not yet supported! I think we could add something with the existing editor.highlight_background API.

If you want to pair with me on this: https://cal.com/conradirwin/pairing

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla-signed The user has signed the Contributor License Agreement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

vim: Add sneak motion
10 participants