Skip to content

Instantly share code, notes, and snippets.

@andersonfreitas
Created November 23, 2012 20:11
Show Gist options
  • Save andersonfreitas/4137085 to your computer and use it in GitHub Desktop.
Save andersonfreitas/4137085 to your computer and use it in GitHub Desktop.
Sublime plugin to convert multibyte strings
# coding: utf-8
import sublime, sublime_plugin
import re
from unicodedata import normalize
class NormalizeSelectionCommand(sublime_plugin.TextCommand):
def run(self, edit):
sels = self.view.sel()
for sel in sels:
selected = self.view.substr(sel)
norm = normalize('NFC', selected)
self.view.replace(edit, sel, norm)
@andersonfreitas
Copy link
Author

{ "keys": ["\\", "m"], "command": "normalize_selection", "context": [{ "key": "setting.command_mode", "operand": true }, { "key": "setting.is_widget", "operand": false } ]},

@andersonfreitas
Copy link
Author

{ "keys": ["super+shift+m"], "command": "normalize_selection" },

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment