sublime in vintage mode - remapping escape failing - sublimetext2

I'm trying to mapp jj to escape. I'm getting an error below. Fix?

I think you should place your configuration code in Default (OS).sublime-keymap, not in Preferences.sublime-settings.
You can find it in Sublime Text 2/Preferences/Key Bindings - User menu.

Open Sublime Text Keybindings Settings Default (Windows).sublime-keymap
Go to Preferences -> Key Bindings - User.
Inside your Default (OS).sublime-keymap file, add your remap..
[
{ "keys": ["j", "j"], "command": "exit_insert_mode",
"context":
[
{ "key": "setting.command_mode", "operand": false },
{ "key": "setting.is_widget", "operand": false }
]
}
]

Related

Is there a CTRL + SHIFT + F for sublime like eclipse shortcut?

(CTRL + SHIFT + F) it's really a nice shortcut to keep code well organized in eclipse. Is there any thing equivalent for sublime text editor?
Unfortunately there isn't a default key binding equivalent to CTRL + SHIFT + F in eclise. However, there is the reindent command that can be used to make your own key binding.
Open the "Key Bindings - User" from your preferences and add this JSON:
[
{
"keys": ["CTRL+\\"],
"command": "reindent",
"args": {
"single_line": false
},
"context": [{
"key": "selector",
"operator": "not_equal",
"operand": "source.js,source.json,text.html"
}]
}, {
"keys": ["CTRL+\\"],
"command": "htmlprettify",
"context": [{
"key": "selector",
"operator": "equal",
"operand": "text.html"
}]
}, {
"keys": ["CTRL+\\"],
"command": "js_format",
"context": [{
"key": "selector",
"operator": "equal",
"operand": "source.js,source.json"
}]
}
]
This will bind -\ to the reindent command (CTRL + SHIFT + F is already taken by "Find in Files"). single_line is false to force it to reindent the whole page, just like in eclipse.
There are two additional variants of the key bindings for working with HTML and JavaScript. These require that you have the htmlprettify and js_format plugins installed. I found the default formatting inferior for HTML and Javascript, so if you are editing these files I do recommend the plugins. If you don't care about these formats, then you can delete the last two key binding entries.
Go to "preferences/Key Bindings" and add on the right panel this line
{"keys": ["ctrl+shift+f"], "command": "reindent", "args": {"single_line": false}}
that line is meant for indenting all your code in one shot so you would ctrl+a then ctrl+shift+f
Sublime has an build-in feature that does indent lines for you. You can find this when opening the command palette, then look for Indentation: Reindent Lines.
Specific actions to organize your code is harder, because of the different syntaxes of languages.
Luckily enough, Will Bond has been so nice to create a Package Manager for Sublime Text. Using this, features can be added into the editor. These packages do can add code formatting features. You can see a list of formatting packages here.
As one of the tags in your question contains HTML, I'll assume you're looking for a formatting tool for HTML. I've found a package for that, although I've got no personal experience with it. You may install it from here.
A plugin for Sublime Text , that formats (indents) HTML source code. It makes code easier for humans to read.
I would recommend reading through the docs for more information about the package.
you can set shortcut key for one line by press [ctrl+shift+f] easy!!!
goto menu Preferences -> Key Bindings – User
{ "keys": ["ctrl+shift+f"], "command": "reindent"}
see detail at http://how-to-sublime-text.blogspot.com/2014/11/reformat-code.html

Sublime Text 2, Tab Key removes selection on single line (instead of indenting)

(Google turns up this http://www.sublimetext.com/forum/viewtopic.php?f=2&t=14005 but that answer isn't satisfactory to me)
In Sublime Text 2, when you hit tab:
If you have nothing selected it will add a tab (or spaces) at your cursor location. This is good.
If you have multiple lines selected it will indent them all. This is good.
If you have a selection within a single line it will replace this text with a tab. This isn't BAD exactly, but it's not what I want. I'd rather it indents that line, as with multiple lines selected.
I'd think the way to do this would be to create a keyboard shortcut that activates if you have text selected when you hit tab, that "command": "indent"s, but I can't figure out how to say "if you have text selected". The keymap documentation seems to be somewhere between impenetrable and nonexistent....
Does anyone know how to get Sublime Text 2 to do what I want?
It's worth noting that if you select text that doesn't include a newline with multiple cursors it replaces the text with a tab.
With that in mind, putting this in my keymap does what I want:
{ "keys": ["tab"], "command": "indent", "context":
[
{ "key": "selection_empty", "operator": "equal", "operand": false, "match_all": true }
]
}
Thank you ! It works fine. Additionaly, you should want the same principle for unindent (shift+tab) :
{ "keys": ["shift+tab"], "command": "unindent", "context":
[
{ "key": "selection_empty", "operator": "equal", "operand": false, "match_all": true }
]
}

What's the command for Replace from Find in Files?

I want to find the command for "Replace" (from the "Find in Files" panel) so that I can assign a keyboard shortcut to it.
Normally I can use sublime.log_commands(True) in the Console Ctrl ` to identify the command, but the Console and Find in Files panels appear on top of each other; so I can't read the Console while I'm using Find in Files.
Control + Alt + Enter
From the default key bindings:
{ "keys": ["ctrl+alt+enter"], "command": "replace_all", "args": {"close_panel": true},
"context": [{"key": "panel", "operand": "replace"}, {"key": "panel_has_focus"}]
}

Make ctrl+space more like Eclipse

In the Default (OSX).sublime-keymap file, I see:
{ "keys": ["ctrl+space"], "command": "auto_complete" },
{ "keys": ["ctrl+space"], "command": "replace_completion_with_auto_complete", "context":
[
{ "key": "last_command", "operator": "equal", "operand": "insert_best_completion" },
{ "key": "auto_complete_visible", "operator": "equal", "operand": false },
{ "key": "setting.tab_completion", "operator": "equal", "operand": true }
]
},
But I'd like it to function more like Eclipse, where methods available get popped up after hitting . and waiting for a split second. Is this possible?
Keep in mind that Sublime Text is not an IDE. As such, Eclipse like completion (where it only brings up methods that you can call for the particular variable) is not built in. You may try something like SublimeJava for completions more like Eclipse. I have used it a bit, with mixed results. It did not work as well as Eclipse, but for what I was doing, it was acceptable. To bring up your current set of completions (from within the file by default) when you press ".", you may add the following to your User Preferences (accessible through Preferences -> Settings - User).
"auto_complete_triggers": [{"selector": "source.java", "characters": "."}]
This will cause the auto complete pop up to be displayed when ever you enter . in java files.

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