Sublime Text 2 & 3 package that adds a command for converting the selected text to a slug.
This package is available through Package Control, it’s called “Slugify”.
Select a piece of text and run “Slugify” from the Command Palette. All characters will be converted to ASCII, removing any punctuation and such, and spaces converted to a separator character that by default is a dash. You can change what separator to use by editing the package setting slugify_separator
, see Preferences > Package Settings > Slugify > Settings — User.
To add a keyboard shortcut for the Slugify command, just bind the name “slugify” to keys of your choice. For example, this binds it to cmd-alt-y:
[
{
"keys": ["super+alt+y"],
"command": "slugify"
}
]
For more information on key bindings, see the Unofficial Sublime Text Documentation.
The slugify function itself is by Armin Ronacher. The plugin part is based on sublime-slug by Damiano Seno.