-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Word movement select from first range, remove unnecessary v #1570
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
base: master
Are you sure you want to change the base?
Conversation
This should close #536. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me!
I think not exactly, this only fixes |
I think I would at least like @archseer to review this. |
I'm still undecided here. With this change |
I think this is better because when you think 3 words, then you press One use case, it's very easy to say you want to delete 3 full words, then For me, I think this builds on top of extends. At least I never had the need that |
Personally, I'd rather leave it as-is, where For example, there was a recent(ish) change that initially surprised me, but which after getting used to I'm quite happy about, where Having said all of that, I don't feel strongly about this, and I acknowledge that sometimes too strict adherence to consistency can harm practical usability. So I'm not specifically opposed, but just have a personal preference to leave as-is. |
I think if that's the case, we can keep it consistent as in |
I've changed my mind on this too, I think |
Is it due to consistency? Like Why is this? In my train of thought, in vim I can do |
Hmm. I see what you mean. So the difference is in how one interprets the count, i.e. does So I guess, what are the pros and cons to each? Right now one can do it either way: Personally, I almost never use counts, so I guess I really don't have a strong opinion one way or the other. Both ways of interpretation make sense to me. But it does seem like the current behavior is more consistent on the whole. |
The new approach can be more consistent once I change the rest, so consistency is not really an issue. Yes, it does lose the ability to select the 3rd word, but why would someone do that? If it is something very useful, wouldn't vim At the same time, even though this may not be a good approach, people can always do One benefit of the new approach over the current approach is that, |
Yeah, for sure, selecting the 3rd word is probably less often desired than selecting the next 3 words, and either way, one can still do |
I also don't feel strongly. (Truth be told, I almost never use the count feature anyway. The point at which the count becomes large enough for me to bother using it is also the point at which I would need manually count the words to know what number to enter, and at that point I might as well just hit |
I'm not sure how important user feedback is to help you decide on how to treat motions in normal mode, but as far as I've seen people are in 2 camps:
In my opinion first is more natural to users, and second to helix maintainers (user is not concerned with how program is made so I think it's more natural to think "select 3 words", and not "use 'w' three times"). I didn't see anyone arguing in favour of 3w selecting 3rd word as functionality (and i've never used that myself, most people in second camp want to keep it as is because of 'consistency', not because they find it useful - at least that's my understanding), so in my humble opinion it would be nice if whole motion would be selected. It would be more in line with what people coming from other editors would expect and would be useful much more often. |
There is a pretty good sign in this and related discussions that the current behavior is unintuitive. Almost everyone in these discussions gets the current behavior wrong. |
I just noticed there are some keys that did this correctly, such as |
I think makes much more sense if the counts, actually extend the selection since in most, if not all, cases the user is actually trying to do an action to multiple items rather than multiply the action. Would simply a lot the action on |
b0abcbd
to
cb85ed4
Compare
New helix user here, just adding my $.02 worth...
👆🏽 This I feel is spot on 💯
As a new helix user (also new to modal editing, so not a previous vim user either) I find it logical to use I think it would be a mistake if prefixing commands change what they do. So with this, But then again, if too many commands extend the selection in normal mode, then what's the point of the selection mode? --
Only because we wouldn't use it, doesn't mean it can't be useful to someone else.
I don't know vim, but I guess Also, I hope helix isn't restricted to copy how vim solves things, but are free to come up with it's own implementations? Edit: To summarize: I'm in favor of keeping it as-is. |
Just so you know, this change will allow you to keep the existing behavior where you can still use |
I suppose I think I am in favour of treating the numeric prefix as a quantifier of "how much/how many" instead of a hard repeat-count (where it makes sense). Would it be possible to create a separate prefix notation for strict repeats? Like |
I have been using this personally for quite some This should be good for review now. 😆 Hopefully @archseer and @the-mikedavis are still around to help review. :D |
|
Not really, |
I think you missed my point of:
That is, I could type |
Why would you think that way? How did you come up with this idea? I have seen lots of example a number followed by something won't be this way. Some examples:
What is your reference point? At least, I never thought about it, or IMHO it is more intuitive for 3wd to delete 3 words. |
It's not my idea, it is how it currently works in Helix; which makes sense to me as it is.
This is comparing apples and pears. Helix is not vim nor are we talking about durations or counting nouns.
My reference point is consistency, and that the number here is used to indicate how many times we want to run the following command. (So agreeing with you here, the number is meant to be a number and not nth. But it is how this number is used that can turn into having the effect of selecting the nth of something.) The The reason I responded in the first place was due to this statement:
Which is true, taken verbatim, but I am affected for my use case of |
As I said up-thread (back in 2022!) I don't actually have a preference one way or the other, because I rarely (if ever) use number-prefixing. However:
I think @kaos's proposed behavior is perfectly valid and understandable. It's just interpreting (Edit: I say his "proposed" behavior, but IIRC that's how it already behaves in Helix.) |
I also don't really have a preference here: I also rarely, if ever, use counts. A count meaning that the command is repeated n times makes sense to me conceptually though. I also think it's reasonable that a count means different things for |
I work on this suggestion as I found Count felt useless and I have to fall back to |
I am a user with no prior vim history, and I can say that, among the small things that sometimes make Helix feel weird, this is by far the largest. Having Edit: Example of difference from
|
I’m honestly surprised this discussion hasn’t already reached a conclusion or been closed. As someone who comes from Vim but understands Helix’s goals, I think it’s important to note: Vim’s In Vim,
People often think “Vim has a built‑in delete‑3‑words command,” but it’s really the inevitable outcome of repeating a motion that returns a range. Helix is a different paradigm:
Here, Changing
Helix should lean into its own model, not mimic quirks that only make sense in the context of another editor’s architecture. |
Thank you very much for your contributions on the technical side! I was not aware of those details about Vim's implementation. I completely agree Helix should lean into its own vision instead of mindlessly replicating others'. However, at least in my case, that's precisely why I advocate for this particular change. Part of the vision (https://github.com/helix-editor/helix/blob/master/docs/vision.md) says that Helix should be "selection > action". As I read it, while it strictly says only "you must select before acting", it implies an editing experience where selecting is a first-class workflow. The current behaviour of these movement keys doesn't offer that, and it has evidently been a pain point for many before (including, perhaps especially, beginners) (as recently as 3 weeks ago!). Now, I haven't used Vim/Neovim, but as I read their docs, it seems they're easily capable of selection-first contiguous (putting aside multiple cursors/selections) editing by using their "visual mode", also activated with So, in this aspect of editing experience, where does Helix improve upon an ostensibly "action-first" editor? It seems mainly to constrain the user option-space by disallowing action-first editing while still requiring, for selections beyond one (1) immediately-contiguous movement unit, the same workarounds that that action-first editor needs to use for its selections. In this sense, Helix seems to already borrow from Vim too heavily instead of leaning on being selection-first. Mind you, I repeat I haven't used vim because I don't want to be told "just go use vim then". I wholly buy into the Helix way of doing things and think it does better when it leans into it. This is for me a step in that direction and improving on what's already there. |
Upon further reflection and studying the codebase a bit more, I believe the disagreement might stem from a fundamental mismatch between the selecting and editing model some users (like me and @pickfire) expect and what other users (like @kaos and @std-enigma) and the code expect. In is particular case, it happens that word movements seem to be somewhat of an inheritance from past models: for the code and latter camp, we can illustrate it by saying Users like me, some of which don't have experience with vim (where movements don't inherently select), see that The full extent and implications of this mismatch is out of the scope of this PR and I intend to flesh it out in a discussion post soon. However, I hope this can contribute to the conversation if it hadn't been considered before. Edit: Phrasing. Edit 2: I found a comment I was looking for, where this mismatch is explicitly articulated: #536 (comment) |
I still think changing Helix already has selection‑first editing with select mode ( Making If we special‑case
From a developer standpoint, the shortcut ( As an experienced Vim user, with the right plugins — especially something like smoka7/multicursors.nvim plus some remapping — you can replicate Helix’s multiple cursors, independent selections, and most of its default behavior without leaving Neovim. Many popular Neovim plugins could technically be done in pure Vim, because Vim’s core has broad, general‑purpose features that can be bent into almost anything if you understand them well enough. But for most people, that’s not appealing — it’s extra effort, extra overhead, and honestly less fun than just installing a plugin designed for that exact job. Which is why I sometimes ask: why not just make a very niche Neovim distribution — configured with Helix‑style keymaps, core plugins pre‑installed, and default behaviors ready to go? You’d get almost the same result without building a whole new editor. Of course, Helix’s philosophy is still distinct: it ships opinionated defaults — completion engine, LSP setup, treesitter, picker — all essentials for coding. In the old Neovim days, getting all this running was… not fun. Telescope(picker) could take at least 300 lines of config. LSPs were worse. Completion engines were over-complicated — even the “easy” one to configure was Node‑based, filled with dependencies you didn’t ask for, slowing things down. Sure, there was I’ll admit, Helix also has quirks I don’t love. For example, deleting a couple of lines above your cursor can take something like But here’s the problem: as soon as that exists, someone will make an issue asking for That’s why I think some things should just stay as they are. On a personal note, I also don’t prefer Helix’s default keybindings. A lot of Vim users trying Helix seem to rebind things back to Vim’s layout. I don’t like using |
Just to add some personal context to my perspective: Helix tempts me because it ships with so many essentials done right out of the box — LSP, treesitter, completion, picker, clean defaults. There’s no plugin hunt, no dependency maze, and no feeling that you need to spend the weekend wiring things together before writing a line of code. I love Neovim’s extensibility. In fact, it’s one of the main reasons I keep using it — the feeling that you can turn it into anything with enough creativity. But that same flexibility is its biggest trap. It’s so easy to turn your Neovim config into an art project: a masterpiece you constantly sculpt and polish instead of actually coding. The plugin ecosystem makes this even easier — and harder to resist. Helix sidesteps that entirely. Fewer knobs, more focus, and no risk of falling down a configuration rabbit hole. It quietly enforces the idea that your editor is a tool first, not a craft project. And yet… I’m not switching. Neovim is too powerful, too familiar, and too much mine to abandon. My plan is to tear down my somewhat bloated setup and rebuild it from scratch — minimal, purpose‑driven, and as close to Helix’s “everything you need in one file” feel as possible. That way I keep the extensibility I love and stay grounded in the tool I’ve used for years — without being tempted away every time Helix crosses my mind. |
Thank you for your thoughtful, thorough response! c: And I appreciate what you and others mean by the count "changing the behaviour of the motion". I truly see it, and while it's true on a technical level, it's not true from some perspectives: as I mentioned above, it depends on your mental interpretation of what the command is for. Now, outside the scope of the PR, but after much reading and experimenting, I can confirm the rest of Helix's motion model is not self-consistent (at least in terms of behaviour). As promised, I elaborated my thoughts in a discussion post (#14468) which I would invite you to have a glance at. It's not perfect, but I believe it helps explain why there has been a lot of confusion and shed light on how to move forward from it. |
Helix is currently inconsistent and this PR attempts to address that. For instance:
(And there are a few similar inconsistencies currently - see the top) |
Even if this PR is not accepted, I doubt the PR that change Side note, some keys like |
3w currently selects the 3rd word, this changes the behavior to select all 3 words rather than just the last.
3w currently selects the 3rd word, this changes the behavior to select
all 3 words rather than just the last.
One of the thing mentioned in #165.
Fix #536
Motivation
Many common motions require prefixing with
v
for count-based operations. For example,v3wd
deletes three words.This PR removes unnecessary uses of
v
where its presence makes no functional difference. It's unlikely users interpret3wd
as "delete the third word",2wwd
aligns better with typical mental models while using the same number of keystrokes.Consistency check
f
/t
/F
/T
]p
]f
- no preference on this, not changing it, I feel like it's weird to 2]f to select 2 functions down from current positionA-n
/A-p
/A-i
/A-o
- keeping, it seemed like these tree-sitter movements affect the whole current selection, I don't get the use case to select until the next two tree-sitter nodesgh
/gs
/gl
- useful to replace/delete till start or end of line, the not obvious ones would begs
from start of whitespace which includes a character, why would someone want to delete till the first character?gs v d
just to delete whitespace (people could justw d
instead)?Common operations
3wd
v3wd
3dw
3Wd
3xd
3xd
3dj
2Jxd
v2kxd
v2kxd
3dk
2Kxd
Side note: https://delapouite.github.io/kakoune-explain/ and https://delapouite.github.io/kakoune-explain/keys.html seems cool