Home Download Buy Blog Forum Support

Selection to Character Entities

Selection to Character Entities

Postby hcabbos on Thu Mar 03, 2011 2:09 pm

The single most used feature for me in TextMate is the ability to select text and convert all special characters to entities. For instance, selecting '…' and converting it to '…'

TextMate even allows you to exclude tags in the case of selecting multiple lines of text. So special characters will be converted but html tags won't.

Is there anything like that in Sublime Text 2?
hcabbos
 
Posts: 11
Joined: Thu Mar 03, 2011 2:03 pm

Re: Selection to Character Entities

Postby hcabbos on Fri Mar 04, 2011 5:09 pm

Wow!!! Works perfectly. Simply awesome! :D

Question: Including the command key on the keyboard doesn't seem to work. Is that key off limits in Sublime Text? I've tried the string "command" and "cmd" and neither execute your code.
hcabbos
 
Posts: 11
Joined: Thu Mar 03, 2011 2:03 pm

Re: Selection to Character Entities

Postby adzenith on Fri Mar 04, 2011 5:54 pm

If you're making keybindings you need to use the word "super" to refer to the command key. I believe this is so that you can use the same keybindings on Linux and OS X.
adzenith
 
Posts: 1214
Joined: Mon Oct 19, 2009 9:12 pm

Re: Selection to Character Entities

Postby hcabbos on Tue Mar 08, 2011 10:51 pm

sublimator wrote:You probably already noticed but it would have still encoded the attribute delimiters.


Nope, hadn't notice yet but much thanks for the update. Installed and works great. I really thank you for the effort.
hcabbos
 
Posts: 11
Joined: Thu Mar 03, 2011 2:03 pm

Re: Selection to Character Entities

Postby pflynny on Mon May 02, 2011 7:23 am

Just started using Sublime Text 2 on a Mac and having an issue getting this to work;

    1) First off I copy this http://pastie.org/private/nd10mq30888zivyavnw5w into a new plugin
    2) Save to Packages>User> as ConvertSpecialCharacters.py
    3) Add this { "keys": ["ctrl+g"], "command": "ConvertSpecialCharacters" } to User Key Bindings.

This looks exactly the plugin I need, any help would be greatly appreciated.
pflynny
 
Posts: 5
Joined: Sun May 01, 2011 11:24 am

Re: Selection to Character Entities

Postby panamajack on Tue May 03, 2011 3:29 am

I think you need to use:

Code: Select all
{ "keys": ["ctrl+g"], "command": "convert_special_characters" }
panamajack
 
Posts: 13
Joined: Wed Apr 13, 2011 3:38 am

Re: Selection to Character Entities

Postby pflynny on Wed May 04, 2011 8:08 am

Thank you panamajack!

This app is getting better and better :)
pflynny
 
Posts: 5
Joined: Sun May 01, 2011 11:24 am

Re: Selection to Character Entities

Postby oscarotero on Thu Jun 30, 2011 11:04 am

This plugin doesn't work for me. I have this code
<div class="t4 b4">
and the plugin converts to
<div class=&quot;t4 b4&quot;>
but it doesn't convert the < and > characters
oscarotero
 
Posts: 1
Joined: Thu Jun 30, 2011 10:55 am

Re: Selection to Character Entities

Postby bizoo on Thu Jun 30, 2011 11:41 am

Dev build 2069 and later introduce a new command in the Command Palette (Tools menu):
HTML: Encode Special Characters

After just a quick look at the code it seems that the plugin here skip tag in the conversion.
bizoo
 
Posts: 879
Joined: Wed Dec 08, 2010 6:53 am
Location: Switzerland

Next

Return to Technical Support

Who is online

Users browsing this forum: No registered users and 24 guests