Skip to content

Commit

Permalink
• Add command to toggle the current word between CamelCase and unders…
Browse files Browse the repository at this point in the history
…core_delimited naming conventions. Currently assigned to control-shift-S, probably want to change that, maybe none by default?

• Add whitespace surrounding slash to "Single / Double" for consistency -- Ruby has "Toggle String / Symbol", might as well use that as the other.

git-svn-id: http://svn.textmate.org/trunk/Bundles/Source.tmbundle@3727 dfb7d73b-c2ec-0310-8fea-fb051d288c6d
  • Loading branch information
Chris Thomas committed Jun 19, 2006
1 parent 41e9efd commit 88991dd
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 6 deletions.
43 changes: 43 additions & 0 deletions Commands/Toggle CamelCase vs Underscore.tmCommand
@@ -0,0 +1,43 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>beforeRunningCommand</key>
<string>saveActiveFile</string>
<key>command</key>
<string>#!/usr/bin/env ruby
# [hH]otFlamingCats -&gt; hot_flaming_cats
def camelcase_to_underscore(word)
word[0] = word[0].chr.downcase
word.gsub(/([A-Z])/, "_\\1").downcase
end
# hot_flaming_cats -&gt; hotFlamingCats
def underscore_to_camelcase(word)
word.gsub(/\_(.)/) {|c| c[1].chr.upcase}
end
word = $stdin.gets
is_camel = word.match(/[A-Z]/) ? true : false
if is_camel then
print camelcase_to_underscore(word)
else
print underscore_to_camelcase(word)
end
</string>
<key>fallbackInput</key>
<string>word</string>
<key>input</key>
<string>selection</string>
<key>keyEquivalent</key>
<string>^S</string>
<key>name</key>
<string>Toggle CamelCase / underscore_delimited</string>
<key>output</key>
<string>replaceSelectedText</string>
<key>uuid</key>
<string>6065BB2D-242A-4C3D-B523-6F560D65AC11</string>
</dict>
</plist>
2 changes: 1 addition & 1 deletion Commands/Toggle Single:Double String Quotes.plist
Expand Up @@ -20,7 +20,7 @@ end
<key>keyEquivalent</key>
<string>^"</string>
<key>name</key>
<string>Toggle Single/Double String Quotes</string>
<string>Toggle Single / Double String Quotes</string>
<key>output</key>
<string>replaceSelectedText</string>
<key>scope</key>
Expand Down
7 changes: 2 additions & 5 deletions info.plist
Expand Up @@ -23,7 +23,7 @@
<string>73EAE95D-A09C-4FC2-B4E3-42505678B57E</string>
<string>3C615C30-0BE1-43D5-896D-74372479FCD1</string>
<string>70A0BC8E-98E0-4D14-B004-7ACA9162B496</string>
<string>4F3DE420-8203-4C57-835D-4C69AEE85B37</string>
<string>6065BB2D-242A-4C3D-B523-6F560D65AC11</string>
<string>------------------------------------</string>
<string>6C601F8C-15B2-43DA-8C39-5DCAD2240424</string>
<string>------------------------------------</string>
Expand Down Expand Up @@ -62,13 +62,10 @@
<key>ordering</key>
<array>
<string>73EAE95D-A09C-4FC2-B4E3-42505678B57E</string>
<string>3DBAEC85-7D09-11D9-A1F6-000D93B6E43C</string>
<string>0526D870-BE98-4931-8DBF-FDD3D405BB1B</string>
<string>88FEF123-77CA-11D9-AC33-000D93B6E43C</string>
<string>D9DFD434-17FE-4491-A182-1B8F8491B3F7</string>
<string>6065BB2D-242A-4C3D-B523-6F560D65AC11</string>
<string>3C615C30-0BE1-43D5-896D-74372479FCD1</string>
<string>70A0BC8E-98E0-4D14-B004-7ACA9162B496</string>
<string>4F3DE420-8203-4C57-835D-4C69AEE85B37</string>
<string>CA1849DD-D6EC-415D-8788-DD93BE027F6D</string>
<string>A72CBA80-5F10-11D9-9B72-000D93589AF6</string>
<string>DE720B53-107F-4AF8-8768-96D25AEBEE6C</string>
Expand Down

0 comments on commit 88991dd

Please sign in to comment.