ctrl+shift+p filters: :st2 :st3 :win :osx :linux
Browse

Sublime​Magic

by mreq ALL

A magic command for sublime. Manage multiple commands with the same hotkey based on advanced contexts.

Details

Installs

  • Total 847
  • Win 577
  • Mac 166
  • Linux 104
May 8 May 7 May 6 May 5 May 4 May 3 May 2 May 1 Apr 30 Apr 29 Apr 28 Apr 27 Apr 26 Apr 25 Apr 24 Apr 23 Apr 22 Apr 21 Apr 20 Apr 19 Apr 18 Apr 17 Apr 16 Apr 15 Apr 14 Apr 13 Apr 12 Apr 11 Apr 10 Apr 9 Apr 8 Apr 7 Apr 6 Apr 5 Apr 4 Apr 3 Apr 2 Apr 1 Mar 31 Mar 30 Mar 29 Mar 28 Mar 27 Mar 26 Mar 25 Mar 24
Windows 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 0
Mac 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 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
Linux 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 1 0 0 0 0 0 0 0 0 0 1

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:

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 match
  • line_matches - an array of patterns that the current line must match
  • selection_empty - when true, some text has to be selected; when false, there must be no selection
  • selection_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

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"
      }
    }
  ]
}