jdavisclark / CaseConversion

Case conversion plugin (pascal, camel, snake) for sublime text 2
MIT License
300 stars 47 forks source link

to_snake_case(text) do not work #3

Closed Exadra37 closed 12 years ago

Exadra37 commented 12 years ago

Hello,

I can exchange to_camel_case and to_pascal_case, but to_snake_case the word remains the same.

Word: example_word

Let me say that i understand php, not python, but i look to your code in case_conversion.py and for a first look you have a function that you don't need:

You deal with underscores in function to_pascal_case at line 27, so is really necessary to use the other function?

Best Regards

jdavisclark commented 12 years ago

So, converting "exampleWord" or "ExampleWord" to snake case has no effect for you? I am not able to reproduce this. The only time converting to snake case does nothing for me is when I try and convert a token that is already in snake case to snake case, which is expected behavior. Please let me know if I am missing something.

In regard to the underscore part: strip_wrapping_underscores and the call to it on line 45 only removes underscores from the very beginning or end of the token, its like trim in php, but for underscore characters. The call to strip_wrapping_underscores on line 45 happens every time, regardless of what conversion you are using. The underscore logic in the to_pascal_case function is how tokens are converted from snake case, which uses underscores to separate words, to pascal case which uses capitalization to separate words.

Exadra37 commented 12 years ago

I start with the word example_word and then apply ctrl+alt+c+p and i get ExampleWord, now i apply ctrl+alt+c+c and i get exampleWord and finally i apply ctrl+alt+c+s and nothing happens and the word still as it is before, that is exampleWord.

If i understand you call strip_wrapping_underscores to remove underscores from _exampleword , so that you can use like example_word to apply camel case or pascal case....

jdavisclark commented 12 years ago

Unfortunately i can not reproduce this behavior, it works fine for me. Il will try it on another computer with a fresh knstall of sublime with no other plugins. Can you try using the snake conversion option in the edit menu and see if that works?

Exadra37 commented 12 years ago

Don't work either in edit menu or in the console, but camel case and pascal case works.

How can i change the keybinding... what command should i use?

I have a fresh install of Sublime Text 2, with the last stable version for 64 bits in Ubuntu 12.04, that is also a fresh install.

Exadra37 commented 12 years ago

I have switched the key binding for to_snake_case and now it works ;)

But i have notice that sublime also have this feature natively...

Thanks for your support :)

jdavisclark commented 12 years ago

Ughh... I truely hate keybinding issues. Some other plugin probably stole it. Unless its a recent addition, sublime does not support this natively. The options you see in the top menu come from this plugin.

Exadra37 commented 12 years ago

Yes you have reason... sublime do not support natively.

The options that i see in the tool bar menu, are from your plugin lool .

Can you add to the tool bar menu, the key binding in use, to look like this "camelCase ctrl+alt+c+c" . I like to see this information, because if i do not use for some time i will forget the key binding ;) .

Another good addition it will have this options, when we click, in the right mouse button ;)