Sublime Forum

ST2: Convert word to snake, camel, or pascal case

#1

Pretty simple but useful plugin. Converts the word currently being touched by the cursor to camel case, pascal case, or snake case.

Source code is hosted at the following locations (with Scott’s contributions):

0 Likes

#2

Update: realized I had camel case and pascal case swapped up, its fixed now.
Install is just a simple copy paste in to your “Packages” directory now, no editing keybinding files either.

0 Likes

#3

[quote=“jdc0589”]Pretty simple but useful plugin. Converts the word currently being touched by cursor to camel case (ctrl+alt+c), pascal case (ctrl+alt+p), or snake case (ctrl+alt+s).
Download: net-machine.com/indefero/p/public/downloads/ and then “CaseConversion.zip”.

This is my first plugin (and first python endeavor) so any feedback, good or bad, is welcome.[/quote]

I modified this to follow pep8 and to work on all selections when doing multi-select and posted it up here:
bitbucket.org/scottbessler/subl … conversion

0 Likes

#4

[quote=“scottbessler”]
I modified this to follow pep8 and to work on all selections when doing multi-select and posted it up here:
bitbucket.org/scottbessler/subl … conversion[/quote]

Great addition and nice to have it on Package Control, thanks for your update.

May I suggest something ?

The first entry in the .sublime-keymap is probably a mistake:

{ "keys": "ctrl+f5"], "command": "refreshFolderList"}, { "keys": "ctrl+alt+s"], "command": "convert_to_snake"}, { "keys": "ctrl+alt+c"], "command": "convert_to_camel"}, { "keys": "ctrl+alt+p"], "command": "convert_to_pascal"} ]
And personally I prefer shortcut for grouped functionality to be also grouped, something like that:

{ "keys": "ctrl+alt+c", "ctrl+alt+s"], "command": "convert_to_snake"}, { "keys": "ctrl+alt+c", "ctrl+alt+c"], "command": "convert_to_camel"}, { "keys": "ctrl+alt+c", "ctrl+alt+p"], "command": "convert_to_pascal"} ]
When you have lot of plugins, it’s become really hard to deal with shortcuts clashes, especially when one plugin define lot of shortcuts.

0 Likes

#5

[quote=“bizoo”]

[quote=“scottbessler”]
I modified this to follow pep8 and to work on all selections when doing multi-select and posted it up here:
bitbucket.org/scottbessler/subl … conversion[/quote]

Great addition and nice to have it on Package Control, thanks for your update.

May I suggest something ?

The first entry in the .sublime-keymap is probably a mistake:

{ "keys": "ctrl+f5"], "command": "refreshFolderList"}, { "keys": "ctrl+alt+s"], "command": "convert_to_snake"}, { "keys": "ctrl+alt+c"], "command": "convert_to_camel"}, { "keys": "ctrl+alt+p"], "command": "convert_to_pascal"} ]
And personally I prefer shortcut for grouped functionality to be also grouped, something like that:

{ "keys": "ctrl+alt+c", "ctrl+alt+s"], "command": "convert_to_snake"}, { "keys": "ctrl+alt+c", "ctrl+alt+c"], "command": "convert_to_camel"}, { "keys": "ctrl+alt+c", "ctrl+alt+p"], "command": "convert_to_pascal"} ]
When you have lot of plugins, it’s become really hard to deal with shortcuts clashes, especially when one plugin define lot of shortcuts.[/quote]

Ah yeah those were just direct copies from the original, I like your suggestions and will throw them in. As a side note, github and in this case bitbucket make it very easy for you to fork my repo, make the change, and submit a pull request to me, try it its fun. :smile:

0 Likes

#6

Thanks for the contributions scott, especially the pep8 update (this was my first piece of python, so it was a little non-standard).

0 Likes

#7

I had forgotten to move the source over to github to make it publicly available. Its now up at https://github.com/jdc0589/CaseConversion with Scott’s contributions.

0 Likes

#8

A few months late in saying this, but glad I could help and thanks for contributing the original code.

0 Likes

#9

Might be nice to map it by default to* - “k”, c* or something similar to the UPPERCASE/lowercase bindings.

0 Likes