SublimeMagic
A magic command for sublime. Manage multiple commands with the same hotkey based on advanced contexts.
Details
Installs
- Total 901
- Win 612
- Mac 176
- Linux 113
| Oct 25 | Oct 24 | Oct 23 | Oct 22 | Oct 21 | Oct 20 | Oct 19 | Oct 18 | Oct 17 | Oct 16 | Oct 15 | Oct 14 | Oct 13 | Oct 12 | Oct 11 | Oct 10 | Oct 9 | Oct 8 | Oct 7 | Oct 6 | Oct 5 | Oct 4 | Oct 3 | Oct 2 | Oct 1 | Sep 30 | Sep 29 | Sep 28 | Sep 27 | Sep 26 | Sep 25 | Sep 24 | Sep 23 | Sep 22 | Sep 21 | Sep 20 | Sep 19 | Sep 18 | Sep 17 | Sep 16 | Sep 15 | Sep 14 | Sep 13 | Sep 12 | Sep 11 | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Windows | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
| Mac | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
| Linux | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
Readme
- Source
- raw.githubusercontent.com
★ SublimeMagic
A magic command for sublime. Create a spellbook, cast spells on your code, make magic happen.
What?
SublimeMagic provides a sublime_magic command, which looks through user-defined actions and performs the first matching one.
Use the spell hotkey!
Default keybind is alt + spacebar but you can set your own. To use the plugin, you have to bind the sublime_magic command.
Regular example:
{
"keys": ["ctrl+,"],
"command": "sublime_magic"
}
Vintageous example:
{
"keys": [" ", " "],
"command": "sublime_magic",
"context": [{ "key": "vi_command_mode_aware" }]
}
Create your spellbook!
The spellbook (your sublime-settings file) consists of a single spells array containing the user-defined spells:
{
"spells": []
}
The spells are iterated one-by-one and the first one matching the context conditions is casted. When there's no spell matching, nothing happens. When there are multiple matching spells, only the top-most one is performed.
Spell
Each spell consists of the following required fields:
nameis the human readable name of your spellspellis the spell code, see “Available spells” for a list of spellsargsspecific to the selected spell
Spells can be limited by settings a context (similar to key bindings, though not using the same syntax). Known context keys:
scope- an array of required scope names (using regexp) - all patterns must matchline_matches- an array of patterns that the current line must matchselection_empty- whentrue, some text has to be selected; whenfalse, there must be no selectionselection_matches- an array of patterns that the currently selected text must match- need more? - make an issue, or even better a PR :)
Spell example
{
"name": "Replace single quoted content with clipboard",
"context": {
"scope": ["string\\.quoted\\.single"]
},
"spell": "replace_text",
"args": {
"where": "inside",
"delimiter": "'",
"replacement": "$clipboard"
}
}
Available spells
- replace_text
- perform_line_regex
- toggle_values
- sublime_command
- more to come - make a PR :)
Example spellbook
Have a nice spellbook? Create a pull request and let me add a link here!
Spellbooks: + mreq
A simple example:
{
"spells": [
{
"name": "Replace single quoted content with clipboard",
"context": {
"scope": ["string\\.quoted\\.single"]
},
"spell": "replace_text",
"args": {
"where": "inside",
"delimiter": "'",
"replacement": "$clipboard"
}
},
{
"name": "Replace double quoted content with clipboard",
"context": {
"scope": ["string\\.quoted\\.double"]
},
"spell": "replace_text",
"args": {
"where": "inside",
"delimiter": "\"",
"replacement": "$clipboard"
}
},
{
"name": "Replace content after colon with clipboard",
"context": {
"line_matches": [": "]
},
"spell": "replace_text",
"args": {
"where": "after",
"delimiter": ": ",
"replacement": "$clipboard"
}
}
]
}