How can I get the same CTRL+W behaviour from Sublime Text - sublimetext3

In the past, ctrl+w used to close a single tab in Sublime Text (3), and if there were no tabs left open, it would close the text editor. How can I achieve the same behaviour in the updated Sublime Text? ST 4
EDIT: The setting I was looking for is "close_windows_when_empty": true

Sublime Text 4 behaves for me as described - it closes all open files and when no files are open, it closes the editor.
However, you may have had your key bindings changed by a plugin/misconfiguration etc.
Preferences > Key Bindings will open up a file.
Ensure that for ctrl+w, the command is set to close not close_file.
Once changed, restart Sublime.
It should look like below:
...
{ "keys": ["ctrl+w"], "command": "close" },
...

Really strange, for me this settings wasn't working:
"close_windows_when_empty": true
tried and tested everything else, finally I've completely uninstalled Sublime 4 and reinstalled it (using AppCleaner, deleted all configs etc).
Now:
"close_windows_when_empty": false
is really set to false, BUT the last window is always closing "everything". exacty what I wanted. It works even the settings tells something else.
So: Reinstall possibly helps

Related

How to disable multiple instances of cursors in Sublime Text 3?

Environment
Sublime Text: 3.1.1, Build 3176
Windows 10
Undesired Behaviour
I must have unintentionally pressed a keyboard combination as I have not had this issue before.
I cannot identify what circumstances create the undesired behavior, but sometimes this happens:
ie, I will be editing some text and realise that the cursor is in 2 (possibly more?) places and everything i am typing is also appearing in multiple places.
Edit: It seems to sometimes occurs after I have Ctrl + V / Ctrl + Shift + V pasted content.
What I've Tried
I've looked at this link, as the title sounded like it might be related:
https://www.sublimetext.com/docs/3/multiple_selection_with_the_keyboard.html
But on closer reading it doesn't seem to be.
I think the following answer might explain the behaviour, but not how to disable it:
https://stackoverflow.com/a/46800245
Desired Behaviour
I'd like to know how to disable the undesired behaviour.
Multiple Cursors on Sublime3, is activated by default either with
ctrl+left mouse button
or by
ctrl+shift+l
disabling ctrl+shift+l:
setting is called split_selection_into_lines. to disable it (Windows):
click Preferences, Key Binding, and on the file Default (Windows).sublime-keymap that will open add the line. (
{ "keys": ["ctrl+shift+l"], "command": "" },
be sure to put this inside the default brackets [ ].
Same is for Linux or Mac, only thing changes is the operating system name on the filename.
disabling ctrl+left mouse button:
Windows - create Default (Windows).sublime-mousemap in %appdata%\Sublime Text 3\Packages\User
Linux - create Default (Linux).sublime-mousemap in ~/.config/sublime-text-3/Packages/User
Mac - create Default (OSX).sublime-mousemap in ~/Library/Application Support/Sublime Text 3/Packages/User
open it with a text editor and paste the following lines in it:
[
{
"button": "button1",
"count": 1,
"modifiers": ["ctrl"],
"press_command": "",
"command": ""
}
]
Save and you are done. In my test, (win10, sublime text 3) method worked instantly, without even restarting Sublime Text 3.

Sublime text editor doesn't auto-refreshes the file if it is modified by another program

Although Sublime is a really powerful text editor but I am facing an issue. I have been using sublime text editor to view logs of my application.Suppose I have already opened file in my editor. After the logs are modified by the app server.
Sublime doesn't give any popup like we get in other editors
Example:
NOtepad++ says:
Also it doesn't modify the file. I have to close the file explicitly and then I re-open the file to ready the modified logs.
Only options i get in my sublime preferences are :
Please help..!
You are using an extremely outdated version of sublime (1.4). You can enable this functionality by upgrading and performing a small settings tweak:
Download the new SublimeText
Install it and open it
Go to the preferences menu and select "settings"
This will open the settings files for sublime, scroll down to line 349 on the left panel and copy that line.
Paste in the copied line into the right pane and replace "false" with "true"
Save and restart SublimeText
This should fix your issue entirely while also upgrading you to the awesome new SublimeText :)
Happy coding!
Set the following setting to true.
Menu > Preferences > Settings
// Always prompt before reloading a file, even if the file hasn't been
// modified. The default behavior is to automatically reload a file if it
// hasn't been edited. If a file has unsaved changes, a prompt will always
// be shown.
"always_prompt_for_file_reload": true

Can't go to next/previous edit point in Brackets with Emmet

Support for Emmet's next and previous edit point seems to be missing or what? Every time I press CTRL+ALT+--> my screen rotates. This is happening on windows only.
EDIT: You can disable the default keyboard shortcuts in control panel but in that case any application won't be able to use those too, nor is there a way remap the keys in Brackets easily!
All available keybindings are defined in keymap.json.
source: https://github.com/emmetio/brackets-emmet
To open this keymap file, first open Brackets, then go to Help > Show Extensions Folder. Open the user folder, then modify keymap.json to however you prefer your shortcuts. Reload Brackets Editor when finished.
My keymap was located inC:\Users\%username%\AppData\Roaming\Brackets\extensions\user\brackets-emmet
You will need to change these two lines:
"next_edit_point": "Ctrl-Alt-Right",
"prev_edit_point": "Ctrl-Alt-Left",

Sublime Text 3: do not close tabs automatically

I am navigating the code of a big JavaScript library using Sublime Text 3. So I need to open a lot of tabs and switch between them to capture the code co-reference. However, Sublime closes 'unused' tabs automatically for me.
How to disable it? I googled but cannot find a solution. I find a shortcut ctrl+shift+t to restore the most recent closed file, but that is not enough. I need to disable the automatic closing, and that would be better if someone shows me the short key to "display and select a file from all open files". Thanks.
When you single-click on a file in the sidebar, Sublime displays it in a "temp" view that is overwritten the next time you single-click on a file. To open a file in a "permanent" tab that stays open even when other files are opened, you simply need to double-click on the file in the sidebar.
A more direct solution that I find mildly preferable, at least until I can retrain myself to double-click when I want a tab to stay open:
In the Settings, set preview_on_click to false.
This is not quite what I want since it all it does is disable the behavior to open a preview tab on single click -- thereby forcing the user to always double click. But perhaps by working this way for a week or so I will be able to retrain my ingrained assumptions and can go back to the default behavior.
Double click that file on left sidebar you do not want to close automatically.

Sublime Text: File remains in tab even after deleted

When I delete a file that I don't need anymore, but then I have to close the tab manually. It is irritating.
Every time, I have to delete the file and then close the tab by confirming the discard changes.
Is there a way to delete the file in one shot.
Please Note: This happens in my MacBook laptop.
If you use the Side​Bar​Enhancements plugin, there is an option for that:
{
"close_affected_buffers_when_deleting_even_if_dirty": true
}
Make sure to add this to the correct settings file:
Preferences >> Package Settings >> Side Bar
I am not 100% clear on the details of your question. Apologies if this answer does not match what you are trying to ask.
Assuming you do not already have the file open this behaviour is a side effect of the choice to preview the file on click.
If this is the use case you are asking about then there is an answer.
If you look in Preferences -> Settings - Default and search for preview you should find this:
// Preview file contents when clicking on a file in the side bar. Double
// clicking or editing the preview will open the file and assign it a tab.
"preview_on_click": true,
This means clicking on the file to delete it causes it to be opened for preview and after deleting the file you also need to close the preview tab.
If you wish to change this behaviour open this file Preferences -> Settings - User and add this line:
"preview_on_click": false,
Then you should not open a preview and therefore will not need to close it after deleting the file.
If you already have the file you are deleting open for editing this will not cause the behaviour you are looking for.
There is an issue, so in order to don't make a link-only answer, I just paste here the main info :
Sublime Forum Question : Close tab after delete file?
Sublime Forum : https://www.sublimetext.com/forum/viewtopic.php?f=2&t=11686
Sublime Forum Answer :
You can do this with a plugin. I didn't really test this much, so you
may want to test on non critical stuff first. It does just close the
view, so worst case is that you lose some existing work. That being
said, I'm pretty sure it works fine.
import sublime_plugin
import os
class MyEvents(sublime_plugin.EventListener):
def on_activated(self, view):
if view.file_name():
if not os.path.exists(view.file_name()):
view.set_scratch(True)
view.window().run_command("close")
There's a plugin for this:
Plugin's Github Page
Seems like it should be a toggleable option.
This was annoying me so much, I created a plugin for it
https://gist.github.com/michaelkonecny/bb5a0d1cf43698c0ebe8673f92324ea3
Just download the close_deleted_files.py file and save it to
%AppData%\Roaming\Sublime Text 3\Packages\User (or similar path on Mac).
This is how the plugin works:
whenever a view is focused, it goes through the filenames of all the tabs in that window and closes those, whose files do not exist.
Extending #jwpfox answer
Below works for me:
Go to -> Top Menu -> Sublime -> Preferences -> Settings
Here Primary Preferences.sublime-settings file is not editable
when you click on settings, so two pages will open, now add the flag on the second page like below .. it will override the primary setting.
Alternatively, you can add the flag in below location file as well directly :
Packages/User/Preferences.sublime-settings
Add flag as
"preview_on_click": false,
The entire file looks like the below:
{
"ignored_packages":
[
"Vintage",
],
"preview_on_click": false,
}

Resources