Home Download Buy Blog Forum Support

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

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

Postby jdc0589 on Fri Jul 01, 2011 11:46 pm

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):
Last edited by jdc0589 on Mon Nov 07, 2011 4:18 pm, edited 7 times in total.
jdc0589
 
Posts: 32
Joined: Fri Jun 03, 2011 2:32 am

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

Postby jdc0589 on Wed Aug 24, 2011 4:15 am

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.
jdc0589
 
Posts: 32
Joined: Fri Jun 03, 2011 2:32 am

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

Postby scottbessler on Thu Sep 15, 2011 1:43 am

jdc0589 wrote: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: http://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.


I modified this to follow pep8 and to work on all selections when doing multi-select and posted it up here:
https://bitbucket.org/scottbessler/subl ... conversion
scottbessler
 
Posts: 3
Joined: Thu Sep 15, 2011 1:38 am

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

Postby bizoo on Thu Sep 15, 2011 3:19 pm

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


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:
Code: Select all
[
  { "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:
Code: Select all
[
  { "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.
bizoo
 
Posts: 877
Joined: Wed Dec 08, 2010 6:53 am
Location: Switzerland

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

Postby scottbessler on Sun Sep 18, 2011 1:30 am

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


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:
Code: Select all
[
  { "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:
Code: Select all
[
  { "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.


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. :)
scottbessler
 
Posts: 3
Joined: Thu Sep 15, 2011 1:38 am

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

Postby jdc0589 on Tue Oct 11, 2011 3:34 pm

Thanks for the contributions scott, especially the pep8 update (this was my first piece of python, so it was a little non-standard).
jdc0589
 
Posts: 32
Joined: Fri Jun 03, 2011 2:32 am

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

Postby jdc0589 on Mon Nov 07, 2011 4:19 pm

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.
jdc0589
 
Posts: 32
Joined: Fri Jun 03, 2011 2:32 am

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

Postby scottbessler on Wed May 16, 2012 7:20 pm

A few months late in saying this, but glad I could help and thanks for contributing the original code.
scottbessler
 
Posts: 3
Joined: Thu Sep 15, 2011 1:38 am

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

Postby wamatt on Fri Aug 17, 2012 10:03 am

Might be nice to map it by default to <super> - "k", c or something similar to the UPPERCASE/lowercase bindings.
wamatt
 
Posts: 17
Joined: Mon Mar 26, 2012 9:59 am


Return to Plugin Announcements

Who is online

Users browsing this forum: No registered users and 10 guests