Search This Blog

Tuesday, October 1, 2013

Sublime macro error

Macros are a very power full tools when working with text editors. If you repeatedly typing the same commands/characters to edit your text you can always try to capture them and save as a macro.


A macro that tries to capture the ALT+F3 keyboard shortcat to highly all the word occurrence in text (more about this here) doesn't work and is erroring out on the console with this message.
Unknown macro command find_all_under


You can reproduce this by trying these steps:
  • Create a new file with this content.
    Line : aaa
    Line : bbb

  • Select menu tools -> record macro in sublime.
  • Highlight the ":" char and press ALT-F3 to mark two lines.
  • Stop macro and save it.
The file should look similar to this one:
   "by": "characters",
   "extend": true,
   "forward": true
  "command": "move"
  "args": null,
  "command": "find_all_under"

When you try to execute this macro it doesn't work and you can see the error message in the console window.

Analysis and solution

The command find_all_under is documented and works fine. You can always try to run it manually from the console yourself.

To create the automatic solution and let the editor to do the work for me I decided to write a Plugin using Sublime Python API. The code works perfectly fine and can be found on my github account: under the file All what you need to do is to install this plugin and execute it manually or use a keyboard shortcat to trigger it.

Workaround example:


Sublime Python API



No comments:

Post a Comment