Alternative to Ctrl+' for Sublime Text - sublimetext2

I've installed latest sublime text 2 version today. I cannot make Control + ` work on 2 different PCs one on Windows 7 the other on Windows 8.1.
In the past I remember it did work.
So what's the alternative ?

Put this in Preferences/Key Bindings -- User and modify the shortcut to something that will work:
{ "keys": ["ctrl+`"], "command": "show_panel", "args": {"panel": "console", "toggle": true} },
By the way: isn't it possible that the second PC has different keyboard layout or that some program is globally overriding that shortcut? As far as I know this keybinding was not changed.

Related

How to save and close tabs with a keyboard shortcut?

I always find myself having at least 10 tabs open in VS Code. I easily get lost in all my tabs and I feel it kills productivity.
Is there a fast key binding to save and close a tab?
One way to save and close an editor at the same time would be with a macro. Using the multi-command macro extension, put this into your settings.json:
"multiCommand.commands": [
{
"command": "multiCommand.saveAndCloseEditor",
"sequence": [
"workbench.action.files.save",
"workbench.action.closeActiveEditor",
]
}
]
and I used this keybinding (keybindings.json):
{
"key": "ctrl+w",
"command": "-workbench.action.closeActiveEditor"
},
{
"key": "ctrl+w",
"command": "extension.multiCommand.execute",
"args": { "command": "multiCommand.saveAndCloseEditor" }
},
First, removing the default Ctrl+W which would close the current tab/editor - but if the file was dirty would stop to prompt to save.
Second, use the same Ctrl+W to trigger the macro. Now the editor is saved first and then closed at once with no prompt.
If you press Ctrl-f4 on unsaved editor, there will be a save-prompt.
You can check the keybindings in VSCode or in this manual https://code.visualstudio.com/docs/getstarted/keybindings
To increase productivity with opened tabs, I use stack-tabs so that the most recently opened tabs are moved to the left automatically. This is very useful to not get lost because the tabs you are working on are often the most recent.
I also use bookmarks to navigate more easily between the code.
I use the Pin feature to keep most important tabs at the left. Then I use alt + 1, alt + 2(, etc..) to quickly select the 1, 2(, etc..) tab at the left.
I use the command "Close All Editors" (#command:workbench.action.closeAllEditors) to close all unpinned tabs at once.
I have set shortcuts to Pin/Unpin & close a pinned tab so I can easily managed pinned tabs.

Does Emmet work with Sublime Text in Vintage Mode?

None of these commands produce a response in Sublime Text 2 on Windows. Emmet is installed. Using vintage mode. Question: how to use Emmet in Vintage Mode on Sublime Text 2?
html:5
div>ul>li
div+p+bq
You can use Ctrl + E to manually expand an abbreviation.
You can also try adding the following to your User keybindings in order to make Tab work normally:
{ "keys": ["tab"], "args": {"action": "expand_abbreviation"}, "command": "run_emmet_action", "context": [{"key": "emmet_action_enabled.expand_abbreviation"}]}

How to configure Sublime Text 2/3 to use direct Ctrl+Tab order and to create new tabs after the last one?

When I press Ctrl+Tab, Ctrl+Shift+Tab or Ctrl+W the tab I get switched to is not the one just near the one I was on (as I would like to) but to some else. When I press Ctl+N the new tab is created right near the tab I am at while I always want it to be created at the end of the tabs list. How to configure it to achieve the behaviour I desire?
To achieve the Ctrl+Tab and Ctrl+Shift+Tab behavior you can add the following lines to your sublime-keymap:
{ "keys": ["ctrl+tab"], "command": "next_view" },
{ "keys": ["ctrl+shift+tab"], "command": "prev_view" }
To open sublime-keymap:
click "Preferences"
click "Key Bindings"
You will see two settings file, select a file that named "User"
This is a visual example on how it should look.
With the default key bindings, ControlPage Up and ControlPage Down will allow you to move right and left among your open tabs, respectively, in their visual order. (The keybinding solution replicates this functionality using your preferred keys.)
Because the package installer is now included with Sublime Text, it's also straightforward to add the MoveTab extension, which adds the shortcuts ShiftControlPage Up and ShiftControlPage Down to move the current tab within that visual order.
To access the package installer in Sublime Text 3 (in Windows, anyway), type ShiftControlp, then Package Control: Install Package.
You can use a plugin to get the new file behavior you want.
import sublime_plugin
class MyNewFile(sublime_plugin.WindowCommand):
def run(self):
window = self.window
view = window.new_file()
active_group = window.active_group()
views_in_group = window.views_in_group(active_group)
window.set_view_index(view, active_group, len(views_in_group) - 1)
Save the above in Packages/User as <somename>.py. Then use the command my_new_file in your key binding for ctrl+n I wouldn't be surprised if there was aplugin to do this already, but it's pretty simple, so easier to write it yourself, than to search package control :) You can likely lose a plugin to do what you want for ctrl+w also, but you didn't describe the behavior you wanted.

Sublime Text Shortcut for Selecting all similarly indented lines

I came across a website that said that CTRL/⌘-SHIFT-J selects all similarly indented text in sublime; however this does not seem to be the case in the actual doc which says:
Added Expand Selection to Indentation (Command+Shift+J on OS X, and Ctrl+Shift+J on Windows and Linux)
Does anyone know the shortcut for this action? This would be really useful to me!
If you open your default key bindings (Preferences > Key Bindings - Default) you can search for "command": "expand_selection", "args": {"to": "indentation"} to see your set key binding.
The full thing looks like this in Linux:
{ "keys": ["ctrl+shift+j"], "command": "expand_selection", "args": {"to": "indentation"} }

Close all tabs, but not the window, in Sublime Text

Is there a way to close all tabs in one go in Sublime Text, but leave the window with the current project open? It is really annoying when I just want to close all open file and start the new task I have to Cmd-W them one by one. If I do Cmd-Opt-W it will close all tabs and the current project.
Thanks to Alex, it turned out kind of simple, Preferences > Key Bindings > User:
{ "keys": ["super+shift+w"], "command": "close_all" }
No need to restart Sublime, it works right away. And what's even better, no need to get used new shortcuts, you can still close Sublime window with Cmd-W after all tabs are gone.
There's an option in the file menu, but it has no shortcut:
File -> Close All Files
Edit - change user settings:
kay, open Preferences -> Key Bindings - User and paste the following between the []:
{ "keys": ["ctrl+alt+shift+w"], "command": "close_all" }
then use Ctrl, Alt, Shift and w to close all tabs.
You'll have to restart Sublime first.
Note: For Sublime Text 3.2.2,Build 3211 you don't need to restart the sublime text to waste your time.Just place code in [ ](as mentioned above),save it and close Key Bindings - User window.Now all opened tabs will be close with out exiting Sublime Text by using Ctrl + Alt + Shift + W .
Here is what I have set up on Mac Sublime Text 3
1. Go to Sublime Text -> Preferences -> Key Bindings - User
2. Add the following binding:
[
... ... ...
{ "keys": ["command+shift+w"], "command": "close_all" }
]
3. Save file
Now, hitting "Command+Shift+W" will close all of your open tabs. Hitting "Command+W" closes current tab only. This is sort of consistent with Mac shortcuts for other app windows.
By default, closing all tabs don't close the window, but beware: The last build 3059 (December 13, 2013) of Sublime Text 3 does now include:
Automatically closing windows when the last tab is dragged out
It is managed by this setting:
// Set to true to close windows as soon as the last file is closed, unless
// there's a folder open within the window. This is always enabled on OS X,
// changing it here won't modify the behavior.
"close_windows_when_empty": false,
I just want to close all open file and start the new task
In that same Sublime Text 3 build 3059, you also have the setting:
When the last file is closed, a new transient file is created automatically
Combined with "File -> Close All Files", that can help starting quickly in a new file.
Go to Preferences>Key Bindings - User> and add following line.
{ "keys": ["super+w"], "command": "close_file" }
Now when you hit cmd+w, only file gonna close not the whole window because you target "close_file".
The Coolest way is :
File - > Close All Tabs
If you are like me, and actually prefer doing right click on a tab and select the Close All Tabs command, you can:
Run the View Package File command in Sublime Text
Select Default/Tab Context.sublime-menu
Add the line:
{ "command": "close_all", "args": { "group": -1, "index": -1 }, "caption": "Close All Tabs" }
Save. Restarting might be required.
Hints:
Tested in ST3, but the documentation I got this from was for ST2, so it should be fine
Do not forget to add a comma at the end of the line if it is not the last
For me it was not possible to edit the Tab Context.sublime-menu file because the folder it is supposed to be in was missing. It that is the case, just create it, for me it was $HOME\AppData\Roaming\Sublime Text 3\Packages\Default\
It is also possible to just create/edit the file directly instead of going through the package viewing process