5

I need to create a new "shortcut" command in Sublime Text to run a BAT file.

I know how to use build_systems and even build_systems per project.

I want to add the command to the command palette list (in the image), and to bind a hot-key for that.

enter image description here

How do I do that?

(I'd prefer not using Python for this)

6
  • 1
    Have you looked at this already?
    – danicotra
    Commented Aug 16, 2015 at 18:43
  • Glad having been of help... I'm still considering if making that suggestion as an answer...
    – danicotra
    Commented Aug 16, 2015 at 19:09
  • You cannot add asnwer just a link, so add a link, short explain, and example of JSON file. You will get my "accepted answer" :) Commented Aug 16, 2015 at 19:34
  • I can't test it by myself in this precise moment, anyway supposing you had no difficulty in installing the package, the JSON should then be the following: { "caption": "Launch Batch File", "command": "open_file", "args": { "file": "path_to_your_file/filename.bat" } } change caption if you wish + file-path and file-name as needed.
    – danicotra
    Commented Aug 16, 2015 at 21:15
  • 1
    P.S. : are you using Windows? If so, supposing your batch file is named "test.bat" and you have it in "D:\myfolder\test.bat" then use "file": "/D/myfolder/test.bat"
    – danicotra
    Commented Aug 16, 2015 at 21:47

2 Answers 2

3

Here is my answer for this:

The steps to follow

  • Install edit-command-palette plugin for Sublime Text (it is easy, so I won't describe how);
  • Edit the command file: from menu "Preferences" select "Command - User";
  • Edit the key bindings file to add hotkeys: menu "Preferences" select "Key Bindings - User".

The command file (second step):

[
    {
        "caption": "moyshale",
        "command":"exec",
        "args": {"cmd": "c:\\drive\\1file\\cp.bat"}
    }
]

Adding a hot-key (third step):

"keys": ["ctrl+shift+y"],
        "command":"exec",
        "args": {"cmd": "c:\\drive\\1file\\cp.bat"}

(It's basically the same, just needs to change keys and caption)

0

i'm use build new system like this definition

{
    "cmd": ["c:/yourpythonpath/python.exe", "-u", "$file"],
    "file_regex": "^[ ]*File \"(...*?)\", line ([0-9]*)",
    "selector": "source.python",
    "env":{"PYTHONIOENCODING":"utf8"}
}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .