Git Product home page Git Product logo

sublimetext-stringutilities's Introduction

SublimeText - StringUtilities

StringUtilities is a Sublime Text 3 plugin, which adds to the editor useful string functions like:

  • Convert Tabs to Spaces
  • Convert Spaces to Tabs
  • Convert Spaces to Non-Breaking Spaces
  • Convert Chars to Html Entities
  • Convert Html Entities to Chars
  • Convert Camel Case <-> Underscores
  • Convert Single Quotes To Double
  • Convert Double Quotes To Single
  • Encode as URL Notation
  • Decode from URL Notation
  • Convert To Unicode Notation
  • Convert From Unicode Notation
  • Convert To Base64
  • Convert From Base64
  • Convert To Hex
  • Convert From Hex
  • Convert HTML Color From Hex To RGB
  • Convert HTML Color From RGB To Hex
  • Calculate Selection MD5
  • Calculate Selection SHA1
  • Convert Unixtime <-> Datetime
  • Insert Current Datetime
  • Generate Password (6 char)
  • Generate Password (8 char)
  • Generate Password (12 char)
  • Generate Password (16 char)
  • Generate Password (32 char)
  • Generate Password (40 char)
  • Generate Password (64 char)
  • Insert Internal IP Address
  • Insert External IP Address
  • Pretify JSON String

Sponsors

No sponsors yet.. :(

If you like the software, don't forget to donate to further development of it!

PayPal donate button

Installation

  • Install Package Manager.
  • Use Cmd+Shift+P or Ctrl+Shift+P then Package Control: Install Package.
  • Look for StringUtilities and install it.

If you prefer to install manually, install git, then:

Clone the repository in a subfolder "StringUtilities" in your Sublime Text "Packages" directory:

git clone https://github.com/akalongman/sublimetext-stringutilities "<Sublime Text 3 Packages folder>/StringUtilities"

The "Packages" directory is located at:

  • Linux: ~/.config/sublime-text-2/Packages/
  • OS X: ~/Library/Application Support/Sublime Text 2/Packages/
  • Windows: %APPDATA%/Sublime Text 2/Packages/

Or enter

sublime.packages_path()

into the console (Ctrl-`).

Usage

  • Right click on editor window (first select text if function is convert type) and select String Utilities menu item.

Todo

  • Add some missed functions

Libraries

  • dateutil by Gustavo Niemeyer is used for adding extensions to the standard python 2.3+ datetime module.. PSF License

sublimetext-stringutilities's People

Contributors

1rover1 avatar akalongman avatar carlosprados avatar donnicojs avatar flashsystems avatar ildarkhasanshin avatar knservis avatar princesseuh avatar rwols avatar ryangreenberg avatar thecotne avatar twista avatar vasfed avatar weisk avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

sublimetext-stringutilities's Issues

global name 'unichr' is not defined

Hi, I got the following error when trying to convert a string into its unicode representation, any idea?

Thanks!

NameError: global name 'unichr' is not defined
Traceback (most recent call last):
  File "/Applications/Sublime Text.app/Contents/MacOS/sublime_plugin.py", line 549, in run_
    return self.run(edit)
  File "/Users/yuanfei/Library/Application Support/Sublime Text 3/Packages/StringUtilities/stringutilities.py", line 110, in run
    text = re.sub(pattern, lambda m: unichr(int(m.group(2), 16)), self.view.substr(region))
  File "./re.py", line 170, in sub
  File "/Users/yuanfei/Library/Application Support/Sublime Text 3/Packages/StringUtilities/stringutilities.py", line 110, in <lambda>
    text = re.sub(pattern, lambda m: unichr(int(m.group(2), 16)), self.view.substr(region))

Add nested menus

If the extra options I have implemented get merged, the right-click menu gets quite long, maybe it would be a good idea to add sub-menus?

Add camelCase/PascalCase option

Hi,

Great plugin. Just found it today.

The Convert Camel Case <-> Underscores is converting from underscores with the first letter capitalized, which is sometimes referred to as PascalCase.

PascalCase is when the first letter of each word is capitalized, while camelCase may or may not have the first letter capitalized.

It would be nice to have an option to choose between the two conventions, either through a different binding or a settings file.

Key binding

How can I convert chars to html entities using key combination?? e.g. Ctr + c

Convert HTML Hex Color to RGB Color and viceversa does not work.

Im testing the plugin and above function does not seem to work. I tried to convert the following hex colors to RGB:

#FFF
#fff
#FFFFFF
#ffffff

It did not work, I also tried to convert RGB to HEX like for example:

rgb(0,2,33);

Did not work either.

Im getting the following errors in the console


Traceback (most recent call last):
  File "/Applications/Sublime Text.app/Contents/MacOS/sublime_plugin.py", line 556, in run_
    return self.run(edit)
  File "/Users/Hyde1942/Library/Application Support/Sublime Text 3/Packages/StringUtilities/stringutilities.py", line 188, in run
    self.view.replace(edit, region, self.hex_to_rgb(text))
  File "/Users/Hyde1942/Library/Application Support/Sublime Text 3/Packages/StringUtilities/stringutilities.py", line 197, in hex_to_rgb
    value = value.lstrip('#')
TypeError: Type str doesn't support the buffer API
Traceback (most recent call last):
  File "/Applications/Sublime Text.app/Contents/MacOS/sublime_plugin.py", line 556, in run_
    return self.run(edit)
  File "/Users/Hyde1942/Library/Application Support/Sublime Text 3/Packages/StringUtilities/stringutilities.py", line 217, in run
    rgb_match = re.match(reg_rgb, text)
  File "./re.py", line 156, in match
TypeError: can't use a string pattern on a bytes-like object

screen shot 2015-10-08 at 7 13 57 pm

Regarding Underscores conversion and uppercase characters

As it stands, converting from Underscores to either camelCase or PascalCase requires only an underscore somewhere in the selection, and for the first character to be lowercase. The current implementation cannot handle strings like a_LL_pointer, turning them into aLlPointer or ALlPointer. What behavior should there be when handling Underscored strings with uppercase letters in these converters? Should the conversion try to support and preserve acronyms (i.e. multiple uppercase characters in a row with at least one underscore before or after)? In light of this, does the requirement for the first letter to be lowercase even make sense? The logic for handling these sorts of cases correctly seems a bit tricky...

An issue remains that the original underscored form wouldn't be discernible from the converted form (e.g. ALLPointer couldn't tell us if we want al_l_pointer or a_ll_pointer, which is even disregarding capitalization). Given this limitation, should attempts be made to modify the behavior of Underscores-> conversion to support strings with capital letters even if camelCase/PascalCase-> conversion cannot reasonably reverse the transformation?

"TypeError: String required"

I get following error when trying to convert camel case text to underscore:

Traceback (most recent call last):
File "...\Sublime3\sublime_plugin.py", line 818, in run_
return self.run(edit)
File "...\Sublime3\Data\Packages\StringUtilities\stringutilities.py", line 117, in run
self.view.replace(edit, region, text)
File "...\Sublime3\sublime.py", line 823, in replace
sublime_api.view_replace(self.view_id, edit.edit_token, r, text)
TypeError: String required

The real issue happens here:

https://github.com/akalongman/sublimetext-stringutilities/blob/master/stringutilities.py#L116

This code may set the variable text to a boolean value, which triggers the "TypeError: String required".

This code may be fixed by replacing it by:

if '_' in text and text[0].islower():
    text = self.toCamelCase(text)
else:
    text = self.toUnderscores(text)

utf8 in base46

this base64 code

4YOU4YOaIOGDpOGDneGDoeGDouGDmOGDoSDhg6rhg5Xhg5rhg5jhg5rhg5Thg5Hhg5jh
g6Eg4YOT4YOQ4YOh4YOQ4YOT4YOQ4YOh4YOi4YOj4YOg4YOU4YOR4YOa4YOQ4YOTIOGD
kuGDl+GDruGDneGDleGDlyDhg5Phg5Dhg5Dhg63hg5jhg6Dhg53hg5cg4YOb4YOd4YOq
4YOU4YOb4YOj4YOaIOGDmuGDmOGDnOGDmeGDoSE6IDxhIGhyZWY9aHR0cCUzQSUyRiUy
Rm15YWxkYWdpLmRldiUyRmdlJTJGcHJvZmlsZSUyRmFjdGl2YXRlLWVtYWlsP2FjdGl2
YXRpb25Db2RlPTYwODY+4YOT4YOQ4YOT4YOQ4YOh4YOi4YOj4YOg4YOU4YOR4YOQPC9h
Pg==

resulted this

�� ������ ��������� ��������������� ������ �������� ������� �����!: <a href=http%3A%2F%2Fmyaldagi.dev%2Fge%2Fprofile%2Factivate-email?activationCode=6086>�����������</a>

this is currect output

ელ ფოსტის ცვლილების დასადასტურებლად გთხოვთ დააჭიროთ მოცემულ ლინკს!: <a href=http%3A%2F%2Fmyaldagi.dev%2Fge%2Fprofile%2Factivate-email?activationCode=6086>დადასტურება</a>

Error while loading plugin

File "/Users/konart/Library/Application Support/Sublime Text 3/Packages/StringUtilities/stringutilities.py", line 269
result = self.from_unix(text) if re.match(ur'^([0-9]+)$', text) else self.to_unix(text)
^
SyntaxError: invalid syntax

Add decoding HeidiSQL passwords

Function on js

function heidiDecode(hex) {
    var str = '';
    var shift = parseInt(hex.substr(-1));
    hex = hex.substr(0, hex.length - 1);
    for (var i = 0; i < hex.length; i += 2)
      str += String.fromCharCode(parseInt(hex.substr(i, 2), 16) - shift);
    return str;
}
document.write(heidiDecode('755A5A585C3D8141786B3C385E3A393'));

Insert External IP throws

I get this in my console when I run Insert External IP:

Traceback (most recent call last):
  File "./python3.3/urllib/request.py", line 1248, in do_open
  File "./python3.3/http/client.py", line 1065, in request
  File "./python3.3/http/client.py", line 1103, in _send_request
  File "./python3.3/http/client.py", line 1061, in endheaders
  File "./python3.3/http/client.py", line 906, in _send_output
  File "./python3.3/http/client.py", line 844, in send
  File "./python3.3/http/client.py", line 822, in connect
  File "./python3.3/socket.py", line 417, in create_connection
socket.gaierror: [Errno 8] nodename nor servname provided, or not known

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Applications/Sublime Text.app/Contents/MacOS/sublime_plugin.py", line 818, in run_
    return self.run(edit)
  File "/Users/rwols/Library/Application Support/Sublime Text 3/Packages/StringUtilities/stringutilities.py", line 430, in run
    response = urllib.request.urlopen(request)
  File "./python3.3/urllib/request.py", line 156, in urlopen
  File "./python3.3/urllib/request.py", line 469, in open
  File "./python3.3/urllib/request.py", line 487, in _open
  File "./python3.3/urllib/request.py", line 447, in _call_chain
  File "./python3.3/urllib/request.py", line 1274, in http_open
  File "./python3.3/urllib/request.py", line 1251, in do_open
urllib.error.URLError: <urlopen error [Errno 8] nodename nor servname provided, or not known>

Context: I type www.google.com, I select it, and then I run this command.

Should it convert entities like &#0000; ?

I have a string like

&#x428;&#x43B;&#x438;&#x444;&#x43E;&#x432;&#x430;&#x43B;&#x44C;&#x43D;&#x44B;&#x435; &#x438; &#x43F;&#x43E;&#x43B;&#x438;&#x440;&#x43E;&#x432;&#x430;&#x43B;&#x44C;&#x43D;&#x44B;&#x435; &#x43C;&#x430;&#x448;&#x438;&#x43D;&#x44B;

This should be HTML Entities and it can be decode to
Шлифовальные и полировальные машины

But it doesn't work.

Port on ST3.

Stringutilities works fine in ST2, but the context menu is unselectable in ST3.
Will this plugin be ported on ST3?
2013-2-28 10-08-48

Unable to load plugin on ST3

dateutil/parser.py in D:\Program Files\Sublime Text Build 3047 x64\Data\Installed Packages\StringUtilities.sublime-package is not utf-8 encoded, unable to load plugin

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.