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

Fix #85 #65 : Make motion inclusive by default, with support for toggling #98

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

myarcana
Copy link

@myarcana myarcana commented Dec 22, 2024

:help forced-motion

I think it would be much more intuitive if hop motions were truly inclusive by default

They were already trying to be, but as #85 points out, it didn't work consistently

I've fixed the behaviour so that hop is always inclusive by default and always consistent, and just like most vim motions, I've also added support to toggle it to be exclusive by pressing v first in operator pending mode (before starting the hop motion, :help o_v)

With this small change, #85's author's snippet

require("hop").setup {}

vim.keymap.set({ "n", "v", "o" }, "f", function()
  vim.cmd "HopChar1CurrentLine"
end, { silent = true })

-- somefn(arg);

Does work exactly the same as the builtin f, try df), df;, dvf;

And if using HopChar1 instead of CurrentLine, then dVf... and d<C-v>f... also behave as you would expect according to all standard vim motions and :help forced-motion.

@myarcana myarcana force-pushed the operator-f branch 2 times, most recently from d91e5c4 to 3fa5075 Compare December 23, 2024 00:14
@myarcana myarcana changed the title Fix #85 Make motion inclusive by default, with support for toggling Fix #85 , #65: Make motion inclusive by default, with support for toggling Dec 23, 2024
@myarcana myarcana changed the title Fix #85 , #65: Make motion inclusive by default, with support for toggling Fix #85 : Make motion inclusive by default, with support for toggling Dec 23, 2024
@myarcana myarcana changed the title Fix #85 : Make motion inclusive by default, with support for toggling Fix #85 #65 : Make motion inclusive by default, with support for toggling Dec 23, 2024
@myarcana
Copy link
Author

I've merged #99 into this, because they don't automatically merge, and they're both solving the same kinds of problem. It makes sense to fix all operator pending behaviour of hop.nvim at the same time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant