Skip to content

Commit

Permalink
Added backslash as separator
Browse files Browse the repository at this point in the history
  • Loading branch information
MattDMo committed Sep 29, 2015
1 parent 1d598b6 commit 5968be8
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 13 deletions.
6 changes: 4 additions & 2 deletions Default (Linux).sublime-keymap
Expand Up @@ -5,5 +5,7 @@
{ "keys": ["ctrl+alt+c", "ctrl+alt+d"], "command": "convert_to_dot"},
{ "keys": ["ctrl+alt+c", "ctrl+alt+h"], "command": "convert_to_dash"},
{ "keys": ["ctrl+alt+c", "ctrl+alt+w"], "command": "convert_to_separate_words"},
{ "keys": ["ctrl+alt+c", "ctrl+alt+/"], "command": "convert_to_slash"}
]
{ "keys": ["ctrl+alt+c", "ctrl+alt+/"], "command": "convert_to_slash"},
{ "keys": ["ctrl+alt+c", "ctrl+alt+b"], "command": "convert_to_back_slash"},
{ "keys": ["ctrl+shift+-"], "command": "toggle_snake_camel_pascal"}
]
1 change: 1 addition & 0 deletions Default (OSX).sublime-keymap
Expand Up @@ -6,5 +6,6 @@
{ "keys": ["ctrl+alt+c", "ctrl+alt+h"], "command": "convert_to_dash"},
{ "keys": ["ctrl+alt+c", "ctrl+alt+w"], "command": "convert_to_separate_words"},
{ "keys": ["ctrl+alt+c", "ctrl+alt+/"], "command": "convert_to_slash"},
{ "keys": ["ctrl+alt+c", "ctrl+alt+b"], "command": "convert_to_back_slash"},
{ "keys": ["ctrl+shift+-"], "command": "toggle_snake_camel_pascal"}
]
1 change: 1 addition & 0 deletions Default (Windows).sublime-keymap
Expand Up @@ -6,5 +6,6 @@
{ "keys": ["ctrl+alt+c", "ctrl+alt+h"], "command": "convert_to_dash"},
{ "keys": ["ctrl+alt+c", "ctrl+alt+w"], "command": "convert_to_separate_words"},
{ "keys": ["ctrl+alt+c", "ctrl+alt+/"], "command": "convert_to_slash"},
{ "keys": ["ctrl+alt+c", "ctrl+alt+b"], "command": "convert_to_back_slash"},
{ "keys": ["ctrl+shift+-"], "command": "toggle_snake_camel_pascal"}
]
4 changes: 4 additions & 0 deletions Default.sublime-commands
Expand Up @@ -27,6 +27,10 @@
"caption": "Convert Case: separate/with/slash",
"command": "convert_to_slash"
},
{
"caption": "Convert Case: separate\\with\\backslash",
"command": "convert_to_back_slash"
},
{
"caption": "Convert Case: Toggle Case",
"command": "toggle_snake_camel_pascal"
Expand Down
3 changes: 2 additions & 1 deletion Main.sublime-menu
Expand Up @@ -13,7 +13,8 @@
{ "command": "convert_to_dot", "caption": "dot.case" },
{ "command": "convert_to_dash", "caption": "dash-case" },
{ "command": "convert_to_separate_words", "caption": "separate␣words" },
{ "command": "convert_to_slash", "caption": "separate/with/slash" },
{ "command": "convert_to_slash", "caption": "separate/with/slash" },
{ "command": "convert_to_back_slash", "caption": "separate\\with\\backslash" },
{ "command": "toggle_snake_camel_pascal", "caption": "Toggle Case" }
]
}
Expand Down
8 changes: 8 additions & 0 deletions case_conversion.py
Expand Up @@ -46,6 +46,10 @@ def to_slash(text, detectAcronyms, acronyms):
words, case, sep = case_parse.parseVariable(text, detectAcronyms, acronyms, True)
return '/'.join(words)

def to_backslash(text, detectAcronyms, acronyms):
words, case, sep = case_parse.parseVariable(text, detectAcronyms, acronyms, True)
return '\\'.join(words)


def to_separate_words(text, detectAcronyms, acronyms):
words, case, sep = case_parse.parseVariable(text, detectAcronyms, acronyms, True)
Expand Down Expand Up @@ -123,3 +127,7 @@ def run(self, edit):
class ConvertToSlash(sublime_plugin.TextCommand):
def run(self, edit):
run_on_selections(self.view, edit, to_slash )

class ConvertToBackSlash(sublime_plugin.TextCommand):
def run(self, edit):
run_on_selections(self.view, edit, to_backslash )
22 changes: 12 additions & 10 deletions readme.md
@@ -1,6 +1,6 @@
# Case Conversion
Case conversion is a plugin for Sublime Text 2. It converts the current word/token between pascal,
camel, snake, dot, dash (hyphen) cases, and separated words.
Case Conversion is a plugin for Sublime Text. It converts the current word/token between pascal,
camel, snake, dot, dash (hyphen), forward slash `/`, backslash `\` cases, and separated words.

## Keybindings
- To snake_case: "ctrl+alt+c", "ctrl+alt+s"
Expand All @@ -9,25 +9,27 @@ camel, snake, dot, dash (hyphen) cases, and separated words.
- To dot.case: "ctrl+alt+c", "ctrl+alt+d"
- To dash-case: "ctrl+alt+c", "ctrl+alt+h"
- To separate words: "ctrl+alt+c", "ctrl+alt+w"
- to separate with slashes: "ctrl+alt+c", "ctrl+alt+/"
- To separate with forward slashes: "ctrl+alt+c", "ctrl+alt+/"
- To separate with backslashes: "ctrl+alt+c", "ctrl+alt+b"
- To toggle between snake_case, camelCase and PascalCase: "ctrl-shift-\_"

## Install
#### Git Clone
Clone this repository in to the Sublime Text 2 "Packages" directory, which is located where ever the
"Preferences" -> "Browse Packages" option in sublime takes you.

#### Package Control
Add https://github.com/jdc0589/CaseConversion as a Package Control repository. CaseConversion will show up in the
package install list.
Open the Command Palette, type ***`pci`*** to bring up **`Package Control: Install Package`**, hit Enter,
then search for `Case Conversion`.

#### Git Clone
Clone this repository in to the Sublime Text "Packages" directory, which is located where ever the
"Preferences" -> "Browse Packages" option in Sublime takes you.

## Contributors
- Davis Clark
- Scott Bessler
- Curtis Gibby
- Matt Morrison

## License
Copyright (C) 2012 Davis Clark
Copyright (C) 2012-2015 Davis Clark

Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
Expand Down

0 comments on commit 5968be8

Please sign in to comment.