Sublime Forum

Need help with JSON for .sublime-commands on Windows?

#1

I’m on Windows and I’m not sure about the correct format I should use for "file":"" in the following .sublime-commands file:

[  
   {  
      "caption":"Do the Foo",
      "command":"run_macro_file",
      "args":{  
         "file":""
      }
   }
]

For example, if this:

"file":"C:\\Users\\Ahu Lee\\YandexDisk\\utils\\Sublime Text Build 3207\\Data\\Packages\\User\\Select Line.sublime-macro"

…then it won’t work, but I can still see the caption. The same with forward slashes (with single backslashes I won’t even see the caption).


What’s the error here? Why won’t it work?

PS The macro file is in the right place and it works via the menu.

0 Likes

#2

Solved

The path should be strictly relative, like this:

"file": "Packages/User/Select Line.sublime-macro"
0 Likes

#3

Nitpicking a bit, the path should be a “resource path”, not a true file path. Resource paths always start with “Packages” or “Cache” and use slashes regardless of platform. A resource path does not correspond one-to-one to a file path, because packages in the Packages directory, installed packages, and the core packages bundled with Sublime all have resource paths beginning with “Packages/<name>”.

0 Likes