Multiple commands with args under 1 hotkey in Sublime Text 3 - json

I'm trying to configure ST3 keybindings to reindent whole text, save file and refresh the browser on ctrl+s. I'm using Chain of Command and Browser Refresh plugins, but the problem is I don't know how to pass commands with arguments, so that the reindent command would affect whole text instead of one line only. "single_line" : false seems to be ignored.
"keys": ["ctrl+3"],
"command": "chain",
"args": {
"commands": [
["reindent",{"context": "window", "args": {"single_line": false}}],
["browser_refresh"]
]
}

I've made it.
"keys": ["ctrl+s"],
"command": "chain",
"args": {
"commands": [
["reindent",{"single_line": false}],
["browser_refresh"]
]
}

Related

In Sublime Text 3, how to have shortcuts for "Build and Run" and "Build only" separately like it was in Sublime Text 2?

In Sublime Text 3,when we press Ctrl+Shift+B, we are given the option to either do "Build and Run" or "only Build", whereas Ctrl+B executes the previously chosen operation among the two. But I want it to be like, it should directly build and run when I press Ctrl+Shift+B and only build when I press Ctrl+B like it was in Sublime Text 2. Can someone help me out?
Addings this to your sublime-keymap should result in the expected behavior:
{ "keys": ["ctrl+b"], "command": "build", "args": { "variant": "" } },
{ "keys": ["ctrl+shift+b"], "command": "build", "args": { "variant": "Run" } },
However you might want to remap keep the list of options to alt+b:
{ "keys": ["alt+b"], "command": "build", "args": { "select": true } },
Not answering the question but good to know, F7 functions the same as Ctrl+b.

Sublime Text Snippets Keyboard Shortcut

I want to create a custom key binding to trigger the Tools > Snippets overlay. I know sublime uses the show_overlay command and overlay enum, but after trial an error I can't figure out what to set the enum to.
{
"keys": ["shortcut"],
"command": "show_overlay", "args": {"overlay": "some_unknown_command"}
}
I'm not looking to insert a specific snippet, just trigger the overlay.
You can find the command by entering sublime.log_commands(True) in the ST console, then using the menu to display the overlay. It will give you the arguments and command you need to use.
{
"keys": [ <your keys here> ],
"command": "show_overlay",
"args": {
"overlay": "command_palette",
"text": "Snippet:"
}
}

Sublime Text: Changing binding for 'unfold' command

In Sublime Text we can change key bindings for our needs. But I can't find way to overwrite basic binding for unfold functionality. I have next code in my Key bindings - User file:
{ "keys": ["ctrl+keypad4"], "command": "fold" },
{ "keys": ["ctrl+keypad5]"], "command": "unfold" },
ctrl+keypad4 works as expected, but binding for ctrl+keypad5 not work at all. How to fix it?
I don't want to change global keymap.
You have an extra close bracket in there. It should be:
{ "keys": ["ctrl+keypad5"], "command": "unfold" },

Opposite of "wrap selection with tag" in Sublime Text 2

Is there a smarter way of removing the tag (let's say using HTML) around a selection in Sublime text 2?
For example if I have a span tag around some text and want to remove both the start and end of this tag (and leave the text inside untouched)...
Or alternative - remove current tag and it's corresponding end tag?
The Emmet plugin (once called Zen Coding) can do what you want. Install it and press Ctrl+Shift+; within a tag's contents to unwrap the tag.
A bit easier way to do this is to use a macro:
unwrap.sublime-macro
[
{
"args":
{
"to": "tag"
},
"command": "expand_selection"
},
{
"args": null,
"command": "copy"
},
{
"args":
{
"to": "tag"
},
"command": "expand_selection"
},
{
"args": null,
"command": "paste_and_indent"
}
]
...with a ctrl+u for example:
{
"keys": ["ctrl+u"],
"command": "run_macro_file",
"args": {"file": "res://Packages/User/unwrap.sublime-macro"}
}
Pros: no plugins required, only default ST functionality. Cons: modifies clipboard data.

In Sublime Text 2 - reopen build output

In Sublimt Text 2, when I use the build system (make) to run tests, the output is displayed in the build output pane.
However, if I press escape to close the output pane (e.g. to make a fix), I can't find a way to redisplay the output pane to see what else was borked. Have tried to create a custom keybinding to execute show_panel "output", but can't get it working.
Meep?
The menu shortcut is under Tools -> Build Results -> Show Build Results.
I wish this was under the View menu like all the rest of view options...
As you can see in Packages/Default/Main.sublime-menu the command for "Show build results" is this:
{
"command": "show_panel",
"args": {
"panel": "output.exec"
},
"caption": "Show Build Results",
"mnemonic": "S"
},
so a custom key binding could be this:
{
"keys": ["ctrl+alt+super+r"],
"command": "show_panel",
"args": {
"panel": "output.exec"
}
}
And the key binding to hide the panel:
{
"keys": ["ctrl+shift+2"],
"command": "hide_panel",
"args": {
"panel": "output.exec"
}
},
Building on akirk's answer you can make it toggle the build results panel by copying some of the syntax used for the escape shortcuts.
Adding the following lines to the user key bindings will do part of the trick. As reported by some of the previous answers the hide_panel command will hide any panel, and pressing it a second time will reveal build_results.
{
"keys": ["alt+b"], "command": "show_panel", "args": {"panel": "output.exec"},"context":
[
{ "key": "panel_visible", "operator": "equal", "operand": false }
]
},
{
"keys": ["alt+b"], "command": "hide_panel", "args": {"panel": "output.exec"},"context":
[
{ "key": "panel_visible", "operator": "equal", "operand": true }
]
},