-
Notifications
You must be signed in to change notification settings - Fork 89
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
surround.vim: yszab) should surround around b #83
Comments
I don't think this should necessarily surround |
But then again, perhaps |
@moll I was thinking of special-handling this particular use-case, since it seems more intuitive. Other operations like
For anything other than surround, I don't think it makes sense to make 2-character sneak an inclusive operation. Vim built-in Surround is a special case, because when you want to surround something, you don't want to target the next two characters after the surround target. Or do you? :) |
I don't know to be honest. Consistency beats intuition because intuition comes from consistency. ;) |
But |
Indeed, but wouldn't you say Sneak behaves more like |
Strictly speaking, it behaves like
True, you land on the first character. But only the first character. Thought experiment: given the text (cursor at column 2):
Built-in Vim motions can toggle inclusive/exclusive with |
I'd say it might warrant another mapping for exclusive sneaking. We're trying to cram
|
I agree with you, moil, with one exception. The way I see two-letter searching is that you wish for the cursor to be on/at the first character, and you're merely just giving the second character for higher efficiency in searching.
I think this should actually be "should delete a, and leave the cursor on b" because there are very few circumstances in which the user desires to delete/yank/use BOTH of the characters they searched for, and it maintains consistency in design and implementation. While I realize that it currently follows the behavior of I would even argue that If Given:
My suggestion is that since sab, in english, is "sneak forward to ab" with the cursor landing on [a], that everything "inclusive" be treated as inclusive (f-like behavior), and that usage with Surround.vim would act as "from cursor position until/forward-to the match" (depending on inclusive/exclusive behavior of sneaking). Personally, I would also like to see inclusiveness/exclusiveness work in a way that would allow you to map a sneak inclusive and a sneak exclusive (e.g. a "f/F t/T" set of bindings) and have everything work seamlessly. This would allow people to easily use sneak.vim as a two-char/one-char replacement for f/F t/T and have the operator actions work intuitively and it would also allow people to have a just inclusive/exclusive binding set or both inclusive/exclusive and have f/F t/T separate, according to their preferences. Thoughts? |
So you, @thang1thang2, propose interpretation and behavior nr 2 from the above list? Quite the set of options we have for
I wouldn't be surprised if we end up having to have two different keys for inclusive and exclusive, like I said before, matching |
So I forgot to reply to this, my bad. (tl;dr at bottom) @moll, I do propose interpretation and behavior nr 2 from the above list. Not as the dominant and only behavior, but as the "f"-behavior side of the plugin with "t"-behavior being possible as well. I've thought about the shortcuts. We currently have 's' to "sneak" and 'z' to "operate with sneak". Going forward towards f/t optional behavior, I might suggest simply overwriting f/t as it would be the easiest option. Otherwise, looking at the mappings, mappings beginning with 'z' handle folds, spelling, and "moving the screen to the right or left", and the only thing capital 'Z' does is act as a speedier :q or :wq. As such, I think they could be safely used as a pair of bindings alongside 's/S' if one is aware of the fact that folds won't work without remapping. As such, using s/S for exclusive and 'z/Z' for inclusive searching could be done relatively seamlessly. Using 'z' and 'x' to work with operators could also be done as that doesn't get rid of any functionality I can see. On further digging through the vim help files, it appears that only a and i are bound natively as text objects which gives us much more flexibility when choosing a binding to work with. As always, one of the larger problems of extending vim remains it's deep coverage of the existing keys. There's a suitable xkcd reference about breaking workflows that applies well here... I would argue for the default overwriting of f/F and t/T going forward. Settings such as The reason I argue that this would be the most sensible way to go is because adding in the ability to choose inclusive/exclusive for any type of behavior of sneak would, in effect, negate the current implementations of f and t for all practical purposes. There is even a current implementation to make sneak one-character, which would be an identical usage of the current f/F t/T with the only change being multi-line behavior. To me, implementing an entirely separate set of keybinds just for vim-sneak seems excessive. While sneak does indeed bridge the gap between f/t and /searching, with the extension of behavior discussed, it would completely emulate f/t, improve it, and extend upon it. It would seem that, at that point, it would be up to the end user to decide what keybinds to use and what features of the plugin to utilize. Thoughts? |
This isn't clear to me. Are you talking about this faq entry or about a proposed new feature? |
@justinmk sorry I wasn't clearer. I meant that having default keybinds for vim-sneak that are different than f/F or t/T seems extraneous if sneak was modified to work both inclusively and exclusively. Right now sneak uses s/S and z for its keybinds. But adding in two extra keybinds just to avoid the usage of f/F and t/T seems largely unnecessary since it's easy for the user to remap the keybinds to whatever they want, anyway. |
Ok, thanks. |
@moll @thang1thang2 Not sure if it covers every scenario mentioned in this issue, but after the changes in #121 you can now toggle inclusive/exclusive behavior (with surround and any other movement/operation) using To see what I mean, compare Try it with other operations too: |
The current behavior is probably most correct, since it matches |
Given this text (cursor at
|
):yszab)
should cause:but instead it causes:
The text was updated successfully, but these errors were encountered: