mreq / SublimeMagic

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

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[Question] Can not begin to work issue

Kristinita opened this issue · comments

Summary

I can not begin to use SublimeMagic.

Expected behavior

Successful begin to use SublimeMagic.

Actual behavior

command: sublime_magic
Traceback (most recent call last):
  File "E:\Sublime Text 3\sublime_plugin.py", line 818, in run_
    return self.run(edit)
  File "sublime_magic in E:\Sublime Text 3\Data\Installed Packages\SublimeMagic.sublime-package", line 13, in run
  File "sublime_magic in E:\Sublime Text 3\Data\Installed Packages\SublimeMagic.sublime-package", line 37, in find_first_matching_spell
TypeError: 'NoneType' object is not iterable

Steps to reproduce

In User folder I create file SublimeMagic.sublime-settings. File contents:

{
    "name": "Replace single quoted content with clipboard",
    "spell": "replace_text",
    "args": {
        "where": "inside",
        "delimiter": "'",
        "replacement": "$clipboard"
    }
}

I add in my User\Default (Windows)\SublimeMagic.sublime-commands these lines:

{
  "keys": ["ctrl+super+,"],
  "command": "sublime_magic"
},

I press Ctrl+Super+, → I get stack trace.

Environment

Operating system and version:
Windows 10.0.14393
Sublime Text:
Build 3126

Thanks.

The SublimeMagic.sublime-settings is not in the right format. You need

{
  "spells": [
    {
      "name": "Replace single quoted content with clipboard",
      "spell": "replace_text",
      "args": {
        "where": "inside",
        "delimiter": "'",
        "replacement": "$clipboard"
      }
    }
  ]
}

@mreq , thank you!

May you add screencasts for all your examples? Without a visual example, users may be poorly understood how SublimeMagic worked.

For example, if I highlight the text use mouse, spell replace_text an example replaces the text that is inside the quotation marks, along with quotes. But if I select text with the keyboard, command sublime_magic not worked for me.

Sublime Magic

@Kristinita just an update, working on some simple screencasts

see https://gfycat.com/SomeKlutzyGoldfinch for an example of Toggle CSS direction

@mreq, for example,

My test.md file:

Саша — Солнечный Яд,
Золотые 'Лучи',
А "они" говорят,
: надо срочно лечить.

My SublimeMagic.sublime-settings file:

{
  "spells": [
    {
      "name": "Replace single quoted content with clipboard",
      "spell": "replace_text",
      "args": {
        "where": "inside",
        "delimiter": "'",
        "replacement": "$clipboard"
      }
    },
    {
      "name": "Replace double quoted content with clipboard",
      "spell": "replace_text",
      "args": {
        "where": "inside",
        "delimiter": "\"",
        "replacement": "$clipboard"
      }
    },
    {
      "name": "Replace content after colon with clipboard",
      "spell": "replace_text",
      "args": {
        "where": "after",
        "delimiter": ": ",
        "replacement": "$clipboard"
      }
    }
  ]
}

Actual behavior:

Actual

  1. If I select line use Ctrl+L, my text don't replace;
  2. If I select line use mouse, my text between "double quoted" replace;
  3. But text between 'single quoted' and after : semicolon always don't replace for me.

It would be nice, if you add more screencasts for your spells. The sooner people understand how it works SublimeMagic, the more people will use SublimeMagic.

Thanks.

Don't select the line. The plugin is aimed to be dead-simple, so having your cursor on the target line is enough.

For your file:

Саша — Солнечный Яд,
Золотые 'Лучи',
А "они" говорят,
: надо срочно лечить.

place the cursor anywhere on the second line and the text in the single quotes will get replaced.