I have split my sublime window vertically to be able to view two files at once. In the explorer window, placed in the left side, it shows two groups, Group 1 which hold "file1" and Group 2 which holds "file2".
Is there a shortcut to change between these two files something like Ctrl + Tab (which only works with files from the current group) ? It's very frustrating to use Ctrl + 0 to point to the side bar and choose with Up Down and Enter.
I'm using Sublime Text 2.
Thanks in advance.
FIX
Actually I've created my own navigator shortcut. In Sublime Text, open Preferences -> Key Bindings - User and added:
[
{ "keys": ["alt+left"], "command": "prev_view"},
{ "keys": ["alt+right"], "command": "next_view"}
]
See this
Ctrl + Page-up && Ctrl + Page-down.
I use these to navigate.
Related
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.
Is there any way to change from, for example, editor to command windows, or current folder etc in Octave? In Matlab, this can be done through the "Next tool", that is "Go to the next workflow step", which I normally set to be "Ctrl+Tab". This means, I just need to repeatedly hit the Ctrl+Tab buttons until I get to the window that I want.
You can see all available shortcuts or set your own from the preferences (Edit -> Preferences -> Shortcuts).
There is no 'rotating' shortcut, but you can set shortcuts to go to the particular window you want directly. The default shortcuts are:
Ctrl + 0 : Command Window
Ctrl + 1 : Command History
Ctrl + 2 : File Browser
Ctrl + 3 : Workspace
Ctrl + 4 : Editor
Ctrl + 5 : Documentation
Ctrl + 6 : Variable Editor
Similarly, adding shift to the above toggles their visibility on or off.
More importantly, if the reason you need tabbing is because you keep having to switch from the console to the editor, note that you can actually drag the editor from its titlebar and place it separately alongside the editor so that the two appear side-by-side.
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.
Cmd-shift-w closes the whole window. I want to just close out a single tab. How do I do that?
Mac: cmd + w
Windows: ctrl + w
Linux : ctrl + w
Hit ctrl+f4 to close a single tab.
To make extra sure go to "Preferences" > "Key Bindings - Default". A file will open displaying the default shortcuts. Search for :
"command": "close_file"
to see your default binding.
Depends on the operating system you're using...
On a mac it's Apple(cmd)+W
This is too old to answer but just in case someone wants to only close a tab/file and do nothing if there is no tab/file open. Just add the following settings to your keybindings.
{ "keys": ["super+w"], "command": "close_file" }
So instead of close, use close_file.
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