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!: 5 new commands to toggle text between PascalCase, camelCase, snake_case, Title Case and kebab-case #12043

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

Conversation

nik-rev
Copy link
Contributor

@nik-rev nik-rev commented Nov 9, 2024

This PR introduces a new mode under ` called "case" mode which has several utility key mappings for working with switching case of text

switch_case, switch_to_lowercase and switch_to_uppercase have been moved to this new mode. 5 new commands have been added and are accessible under ` as well:

Key Description Command
`l Switch text to lowercase switch_to_lowercase
`u Switch text to UPPERCASE switch_to_uppercase
`p Switch text to PascalCase switch_to_pascal_case
`c Switch text to camelCase switch_to_camel_case
`t Switch text to Title Case switch_to_title_case
`s Switch text to snake_case switch_to_snake_case
`k Switch text to kebab-case switch_to_kebab_case
`a Switch text to aLTERNATE cASE switch_to_alternate_case

Closes #5197


Unlike #4615 this PR doesn't pull in any extra dependencies. It builds on top of the existing case_conversion.rs module and adds many tests to make sure that functionality is correct. The tests even fixed some edges with the existing camelCase implementation

Breaking changes

Remaps several keys:

old new
Alt-` `u
` `l

Renames a command:

old new
switch_case switch_to_alternate_case

@nik-rev nik-rev changed the title feat: commands to toggle text between Pascal Case, camelCase, snake_case, Title Case, snake_case and kebab-case feat: 5 new commands to toggle text between PascalCase, camelCase, snake_case, Title Case and kebab-case Nov 9, 2024
TornaxO7

This comment was marked as off-topic.

@nik-rev
Copy link
Contributor Author

nik-rev commented Nov 20, 2024

Interesting feature idea, however, I'm a bit unsure if this might be more suitable as a plugin than as a core feature.

Imo, it shouldn't be a plugin. This is a useful feature that is handy to have in an editor when you need it, but it's not something you know you need until you need it.

@nik-rev
Copy link
Contributor Author

nik-rev commented Nov 20, 2024

Interesting feature idea, however, I'm a bit unsure if this might be more suitable as a plugin than as a core feature.

Btw, I only replied now because your reply was marked as "off topic" before

How do comments get marked as off-topic? Is it automatic ,or someone marked yours?

@TornaxO7
Copy link
Contributor

How do comments get marked as off-topic?

You can mark your own comments as off-topic but I also think that the repo owners are able to mark comments as offtopic as well.

Is it automatic ,or someone marked yours?

I did it myself because I thought that my comment there might be not that "helpful" so I just marked it as "offtopic", just to be safe :)

@kirawi kirawi added the A-command Area: Commands label Nov 26, 2024
helix-term/Cargo.toml Outdated Show resolved Hide resolved
book/src/keymap.md Outdated Show resolved Hide resolved
@gabydd
Copy link
Member

gabydd commented Dec 20, 2024

We have case conversion in helix core from the snippets system which should be used instead of another dependency https://github.com/helix-editor/helix/blob/master/helix-core%2Fsrc%2Fcase_conversion.rs

@darshanCommits
Copy link
Contributor

Hopefully this gets merged, now that it's not even pulling dep.

@nik-rev nik-rev force-pushed the feat/different-case-modes branch from d010828 to ad13dd5 Compare December 20, 2024 07:44
@nik-rev nik-rev marked this pull request as draft December 20, 2024 08:02
@nik-rev nik-rev marked this pull request as ready for review December 20, 2024 09:42
@nik-rev nik-rev changed the title feat: 5 new commands to toggle text between PascalCase, camelCase, snake_case, Title Case and kebab-case feat!: 5 new commands to toggle text between PascalCase, camelCase, snake_case, Title Case and kebab-case Dec 20, 2024
rockboynton pushed a commit to rockboynton/helix that referenced this pull request Jan 2, 2025
`patchy` is a tool which makes it easy to declaratively manage personal forks by automatically merging pull requests.

Check it out here: https://github.com/NikitaRevenco/patchy
rockboynton pushed a commit to rockboynton/helix that referenced this pull request Jan 2, 2025
`patchy` is a tool which makes it easy to declaratively manage personal forks by automatically merging pull requests.

Check it out here: https://github.com/NikitaRevenco/patchy
@nik-rev
Copy link
Contributor Author

nik-rev commented Feb 3, 2025

I added back the ~ mapping, as I realized it's too much of a breaking change to remove it (Vim had it for decades, and Helix...). It's okay to have 2 keys that do the same thing, e.g. we have Ctrl-c and Space-c

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.

More case conversions
6 participants