Sublime Forum

Selection to Character Entities

#1

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?

0 Likes

#2

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

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.

0 Likes

#3

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.

0 Likes

#4

[quote=“sublimator”]You probably already noticed but it would have still encoded the attribute delimiters.
[/quote]

Nope, hadn’t notice yet but much thanks for the update. Installed and works great. I really thank you for the effort.

0 Likes

Typography plugin (or clever find and replace)
#5

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

  1. First off I copy this 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.

0 Likes

#6

I think you need to use:

{ "keys": "ctrl+g"], "command": "convert_special_characters" }
0 Likes

#7

Thank you panamajack!

This app is getting better and better :smile:

0 Likes

#8

This plugin doesn’t work for me. I have this code

and the plugin converts to
but it doesn't convert the < and > characters
0 Likes

#9

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.

0 Likes

#10

It’s ignores tags but it converts comments.

For example it will turn an HTML comment into:

&lt;!-- comment --&gt;

Instead of:

<!-- comment -->
0 Likes