Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
• Add command to toggle the current word between CamelCase and unders…
…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
Showing
3 changed files
with
46 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 -> hot_flaming_cats | ||
def camelcase_to_underscore(word) | ||
word[0] = word[0].chr.downcase | ||
word.gsub(/([A-Z])/, "_\\1").downcase | ||
end | ||
# hot_flaming_cats -> 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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters