sublime text 3 code folder short cut key definition is not working - sublimetext2

I am trying to use code folding command, but the short-cut is not working. I have to use menu, which is not convenient.
What does the "," mean in short cut? I tried the short cut on both side of the ",". They all not working. command + K is not working.
I think the reason is there is conflict here:
Then I try to configure a unique short cut key, which is also not woriking. Here is my configure
[
{"keys":["super+;"],"command": "run_macro_file", "args": {"file":"Packages/User/Semicolon.sublime-macro"}},
{ "keys": ["ctrl+enter"], "command": "open_in_browser"},
{ "keys": ["alt+d"], "command": "goto_definition" },
{ "keys": ["command+9"], "command": "fold_level_9" } // here is the definition
]
Can you please tell me what I did wrong?
How do I make the code folding short-cut work?
Thank you!

⌘K, ⌘3 means you hit ⌘K, release both buttons, then hit ⌘3. Sublime allows these compound keyboard commands, and recognizes it as different from ⌘3 alone. Try removing your custom shortcut keys (as they may be interfering with other commands) and seeing if the built-in commands work now.

Related

sublime text 2 reindent single-line true vs false

I'm new to sublime text 2, and would like to figure out how to reindent my code properly.
There's certainly the menu item: Edit->Line->Reindent, but I would like to have a keyboard shortcut.
I read this thread: Sublime Text 2: Auto fix indentation for javascript?
Helpful, so I've setup the following two shortcuts:
[
{ "keys": ["f5"], "command": "reindent", "args": {"single_line": false} },
{ "keys": ["tab"], "command": "reindent", "args": {"single_line": true} }
]
I'm trying to sort out the difference between single_line:true and single_line:false. At first, it seemed that single_line:false simply reindents the entire file. But upon closer inspection, it seems to reindent differently.
Take this single line example of javascript code:
var app = angular.module('indexApp', ['chart.js', 'ui.toggle']);
Hitting F5 (single-line:false) keeps the line at the left margin (which seems correct to me)
Hitting TAB (single_line:true) indents the line by one
Hitting F5 toggles it back to the left margin.
So, what's the single_line:true/false really mean ?
Hmmm, it looks like 'single_line' is not my issue here.
Looks like this is my issue: https://github.com/SublimeTextIssues/Core/issues/1271
There seems to be a feature that is causing Javascript (and other) comments to not be indented "correctly". (at least according to my definition of correct).
The fix in the linked issue above works for me... (though I'm guessing I'll lose the fix if I ever update ST) ?

Insert custom characters and move mouse pointer to certain position

I face some issue when trying to add custom key-blinding under Sublime Text 3.
Go under Under Preferences->Key Binding- Users.
Add { "keys": ["alt+k"], "command": "insert", "args": {"characters": "d();"}}
When i Press Alt+k will return me this d(); <-Mouse Pointer end after the semicolon
What i wish to achieve is something like d(Pointer); after press Alt+k <-Mouse Pointer within the braces.
I try figure out some key-Binding Style in the default one but cant find any useful.
PS:I know "command": "move" able to move pointer position but how to combine this with insert,Thanks.
You can archive this behavior without chaining commands with a snippet. Just use this keybinding:
{
"keys": ["alt+k"],
"command": "insert_snippet", "args": {
"contents": "d($0);"
}
},
Where $0 defines the cursor position. You can even use ${0:$SELECTION} to optionally surround the selected text.
To address your PS: If you are interested in chaining commands, then the Chain of Command package could be interesting for you.

custom keybinding on find and Reg replace in sublime text?

Am thinking whether it's achievable to make shortcut key-bindings on user
sublime key-map, so that one-key-triggered "find reg expression and replace-all"
if can assign custom keybinding will save a lot of work.
For example can be applied to make below answer into shortcut:
Sublime Text 2: How to delete blank/empty lines
Thanks to Joyas's answer, Below is the usage that could achieve the above task.
1.install RegReplace plugin for sublime 2/3
2.configure user reg replace function
{
"replacements": {
"remove_blank_lines": {
"find" : "(^\n)",
"replace": "",
"greedy_replace": true
}
}
}
3.configure key bindings
{
"keys": ["ctrl+shift+y"],
"command": "reg_replace",
"args": {"replacements": ["remove_blank_lines"]}
}
go to font-end press shortcut and it works so good!
There is already a post here about custom shortcut in sublime text.
In order to change the default shortcut for find and replace, you just have to edit de the line
{ "keys": ["super+shift+f"], "command": "show_panel", "args":
{"panel": "find_in_files"} }
in you preferences.
Furthermore, if you want to create a keybinding in order to "find and replace" a specific sequence of character, it seems that there is the plugin RegReplace to do so.

How do I insert a snippet of text using a keyboard shortcut in Sublime Text?

How do I set a shortcut for inserting console.log() and wrapping it around my current selection in Sublime Text without installing any plugin or extra third-party stuff?
So I found the answer. Thought I'd add it here for others:
Go to Sublime Text 2 > Preferences > Key Bindings - User and add this JSON to the file:
[
{ "keys": ["alt+d"],
"command": "insert_snippet",
"args": {
"contents": "console.log(${1:}$SELECTION);${0}"
}
}
]
Inserts a console.log() at the current cursor position on pressing alt+d.
Reference: https://gist.github.com/harthur/2951063

Bind command show_at_center to space bar in Sublime Text 2

In vim, in command mode, I'm quite fond of using the space bar to center the current line on screen. nmap <space> zz maps this functionality to the space bar in my gvimrc file. I'm trying to bind the same functionality to the space bar in Sublime Text 2:
{ "keys": ["space"], "command": "show_at_center", "args": {"command_mode": true} }
The line above doesn't work. Can anyone tell me why, and what will? I have Sublime's Vintage mode enabled. Also, I have “scroll_past_end”: true in my Sublime Text 2 User Preference Settings so that even the last lines of a file can be centered.
Try adding the following to Packages/User/Vintage/Default (<your OS>).sublime-keymap:
{ "keys": ["space"], "command": "show_at_center",
"context":
[
{ "key": "setting.command_mode"}
]
}
I can't test it right now, but it should work :)
EDIT - it doesn't. See below...
UPDATE
So I've searched far and wide, and it seems that, for whatever reason, you cannot assign an action to space on its own. Assigning it to Altspace works just fine:
{ "keys": ["alt+space"], "command" : "center_on_cursor",
"context": [{"key": "setting.command_mode"}] }
as does assigning it to a function key (F7, for example), or even to a single letter, like M. However, space on its own only results in the cursor moving one character forward when in command mode. The good news is that hitting z,z (lowercase) whilst in command mode will do what you originally wanted to do, which is center the cursor (as does CtrlL, as you indicated). Unfortunately, it is not possible to remap this action onto the spacebar on its own. The programmed action of space in command mode,
set_motion {"clip_to_line": true, "motion": "vi_move_by_characters", "motion_args": {"extend": true, "forward": true, "visual": false}}
just seems to be hard-programmed in. Sorry.