Sublime Text: Changing binding for 'unfold' command - sublimetext2

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" },

Related

switching between tabs in sublime "ctrl+tab"

Anyone notice that the default ctrl+tab doesn't work like the typical consecutive tab switching from left to right, e.g., in Chrome? I'm trying to switch to the next adjacent tab, but it seems to jump around (alphabetic order I think).
How can I change the order in which sublime switches tabs?
The default behavior is to goto tab you have used at last. Just add this keybinding to your user keybindings:
{ "keys": ["ctrl+tab"], "command": "next_view" },
{ "keys": ["ctrl+shift+tab"], "command": "prev_view" },
In sublime text 3, there is shortcut to switch tab in similar to ctrl+tab in browser.
{ "keys": ["ctrl+pagedown"], "command": "next_view" },
{ "keys": ["ctrl+pageup"], "command": "prev_view" },
While this ctrl+tab has behavior similar to windows alt+tab to switch apps. CMIIW.
{ "keys": ["ctrl+tab"], "command": "next_view_in_stack" },
{ "keys": ["ctrl+shift+tab"], "command": "prev_view_in_stack" },
You can just make custom key binding and swap them around.
And for anyone looking for shortcut to move tab to left & right, there is a plugin for that.
please try command + shift + ] .This will bring you immediately to the next tab.
Command + Ctrl + P : Switch between the projects that are listed on the sublimeText Sidebar.

Multiple commands with args under 1 hotkey in Sublime Text 3

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"]
]
}

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:"
}
}

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.

Change "Next File" and "Previous File" shortcut in Sublime Text 2

I'm having no luck changing the key bindings for switching files in Sublime. Does anybody know that the deal is here? All i'm trying to achieve is cmd+] and cmd+[ to show next and previous files. Then i can use tab and shift+tab for all my indenting.
[
{ "keys": ["super+]"], "command": "Next File" },
{ "keys": ["super+["], "command": "Previous File" }
]
Thanks everyone!
This is actually what you might have been really looking for. I find it more useful to go back to the previous file I was working on, not moving left and right through the tabs. But you can have bindings to both behaviors.
// This is very useful, go back to the previously viewed file regardless of
// tab order
{ "keys": ["super+["], "command": "next_view_in_stack" },
{ "keys": ["super+]"], "command": "prev_view_in_stack" }
Try this:
[
{ "keys": ["ctrl+]"], "command": "next_view" },
{ "keys": ["ctrl+["], "command": "prev_view" }
]
Of course this goes into the "Key Bindings - User" file.