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

feat: new subword text object #12026

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

Conversation

NikitaRevenco
Copy link

@NikitaRevenco NikitaRevenco commented Nov 7, 2024

this is a new text object which operates on parts of snake_case, kebab-case, camelCase, PascalCase and /path/case

It's a subword, so it's mapped to s

Below is a table showcasing various use-cases of this new text object. * is just an indicator for where the cursor is and is not part of the text

mis selects an inner subword, mas selects an outer subword which includes the delimiter. d deletes the selection.

before inner (misd) outer (masd
snake_case_lon*g snake_case_ snake_case
snake_ca*se_long snake__long snake_long
snake__ca*se__longier snake____long snake__long
snake__case__long*ier snake__case__ snake__case
c*amelCaseLong camelCase CaseLong
camelCa*seLong camelLong camelLong
camelCAseNotRE*Ally camelCAseNot camelCAseNot
camelCA*seNotREAlly camelNotREAlly camelNotREAlly
snake_Ri*ding_a_Camel_Case snake__a_Camel_Case snake_a_CamelCase
sn*ake_Riding_a_Camel_Case _Riding_a_Camel_Case Riding_a_Camel_Case
P*ascalCaseLong CaseLong CaseLong
tast*y-kebab-case -kebab-case kebab-case
tasty-kebi*ab-case tasty--case tasty-case
path/som*ewhere/../case path//../case path/../case
../.*./path/case/ ..//path/case ../path/case
../path/case/som*ewhere ../path/case/ ../path/case

@NikitaRevenco NikitaRevenco changed the title feat: new "subword" text object feat: new subword text object Nov 8, 2024
@JeftavanderHorst
Copy link
Contributor

I'm certainly not opposed to this being merged, but when I implemented #8147, I didn't feel the text object was necessary, since you can emulate match_inner_sub_word by chaining move_prev_sub_word_start and move_next_sub_word_end, which is the same amount of keypresses (depending on your config).

@NikitaRevenco
Copy link
Author

NikitaRevenco commented Nov 8, 2024

I'm certainly not opposed to this being merged, but when I implemented #8147, I didn't feel the text object was necessary, since you can emulate match_inner_sub_word by chaining move_prev_sub_word_start and move_next_sub_word_end, which is the same amount of keypresses (depending on your config).

I mean, similar can be said about word, for example. You can use be to select the inner word, but it's really handy to have a word text object at your disposal.

Another benefit is that you don't need to think about which keys specifically to use, or assign them yourself.

@kirawi kirawi added the A-command Area: Commands label Nov 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-command Area: Commands
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants