Neovim plugin to toggle string casing
In my line of work I usually write code in JavaScript / TypeScript, and to a lesser extend Rust. I also deal with other languages frequently like bash, python, etc, but the latter two are the main ones. Specially in my js/ts work, something I encounter very frequently are mismatches between the casing types.
So, js/ts uses camelCase by default. That's the standard. But I deal with a lot of external APIs coming from other languages (or maybe the same language but with a different pattern).
So I find myself spending a lot of time converting casing from paid_amount to paidAmount and vice-versa frequently.
I've always wanted to speed this up, because usually I need to do a lot of f_lVuhx in Neovim.
I've always wanted a keybinding to automate this for me, so I ended up writing a binary and a corresponding neovim plugin: it's in Codeberg;
It was mostly build using Claude (I don't really know Lua).
The package could use some major improvements, like only downloading what's required to run the tool in Neovim, including downaloading only the binary for the user's platform, but it's a nice start for now.
I'm using Lazy, so to setup the plugin, I just do:
{
'drawings_and_code/toggle_case',
url = 'https://codeberg.org/drawings_and_code/toggle_case',
config = function()
require('toggle_case').setup()
end
}
The repository has the code to set up keybinding. With them, to change the casing of a string, all we need is to select a string like paidAmount with viw and use <leader>tc.
The string will be converted into camel case: paidAmount. There are other casing options available:
- camelCase
- kebab-case
- PascalCase
- snake_case
- SCREAMING_SNAKE_CASE
With this little plugin, I'm pretty sure I'll be saving several milliseconds PER WEEK!