Sublime Text: File remains in tab even after deleted - sublimetext3

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

Related

After opening a folder in Sublime Text 3, how do I open two files at once?

I'm using MacOS 10.12.
I open a folder in Sublime Text 3 and I click a file.
The file then appears as a tab on the right side.
If I don't edit it and try to open another file, the previous one will be replaced by the new file.
My question is: how do I open the second one without having to edit the first one?
For now, my solution is to press a blankspace and delete it in the first file (so nothing changes here). And then open the second file.
This is annoying, and I figure there might be a better solution for this.
Thanks in advance.
By default, the following preference is set:
// 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 that a single left click on a file in the sidebar will open a preview/transient tab. Single left clicking on another file will replace that tab with a preview of the new file. As you have noticed, editing the file in some way will convert the tab from a preview to a persistent tab. Setting this preference to false will mean that single clicking will do nothing. There is currently no option to get the file to open in a persistent tab from a single click.
Regardless of this preference, double left clicking will open the file in a tab that will stay.

Sublime Text 3 settings always lost in a new file

I've switched to sass recently because I like the indented flavor of it but now I have a problem with my SB3 text editor:
My initial tab settings are too big for sass (it just takes too much place tab size is set by default to 4) so what I did to change that I just went to
Preferences -> Settings More -> Syntax Specific User
And then I added:
{
"tab_size": 2,
"translate_tabs_to_spaces": true
}
And here is the trick, it works on the document itself only when I create/open a file and then press tab it's like I never changed it but within the settings document it works perfectly, I have tried many solutions but none of them were successful
The answer was provided to me by sergioFC ! Thanks a lot man !
The answer is that those spec setting depends on what file you are at the moment when you open the spec.
For example if I have a .css file, and I open the Syntax Specific user, everything I write in you will be applied only to the files that have the same extension.
Thanks a lot # sergioFC !!!

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.

how to enable soft tabs textmate2

i've seen some other answers to this but my textmate is behaving funny. i can't enable the soft tabs, which is getting annoying now that I'm working with haml. any ideas?
attached screenshot, the softtabs option is greyed out. what am I missing?
thanks,
JD
If you want Soft Tabs enabled everywhere add the following to the .tm_properties file in your home dir. If you don't have it just create one.
If you want to enable it for a specific project only simply create a .tm_properties file in the project dir.
softTabs = true
tabSize = 4
If you want to enable Soft Tab only for certain file types you can add a section to the file like this:
[ *.coffee ]
softTabs = true
tabSize = 2
I would recommend you to check out how these files work. Here is an example by hmans.
Also check out Textmate 2 Tips for more info.
Update
As Michael Sheets writes in his answer, it is now possible to save the change through the GUI.
As of r9290 you can now change the tab settings from the menu at the bottom of the edit window and they will be saved for the current file type and parent file type if applicable.
These are saved into Global.tmProperties which you can read more about in the release notes for r9290 (Help → Release Notes).

Where does notepad++ store style configurator settings?

I downloaded and modified a style file and placed it in the Notepad++ themes folder. I was able to select it and have it update the style as expected. I then went to Settings -> Style Configurator and changed the font of COMMENT of language VHDL to MS Gothic, hit save, and closed and exited Notepad++. I am able to relaunch Notepad++ and still see the change (I'm running Notepad++ in admin mode on Win7).
The only file that I can see a new timestamp on is my XML theme file, but I don't see MS Gothic anywhere in the file. Where is this information being stored? It is overriding the settings from my theme file. I also checked %APPDATA%\Notepad++\stylers.xml but I don't see it there either.
I realize I can change it back through the GUI, but I'd like to know how to get back to my original theme without selecting every style in the language manually (as I've made multiple changes). If I could edit (or delete) a file, I would prefer it.
Look in your %APPDATA%\Notepad++ folder, specifically for the stylers.xml file.
Uninstall Notepad++
Reinstall it again, but this time check the first box, the one that says "Don't use %APPDATA%..... "
Enjoy.
The reason is that Notepad++ install all the files at administrator profile, if you are using another user then you are screw, it will not work properly, you have to run it always as an administrator so it can work properly. To avoid this, just do as i said.
If files are going to APPDATA, then you can create a folder called "themes" and then inside that place your new xml themes. Then close and reopen notepad++ and you should see your new style in the "Select theme:" drop down. Whatever you named the file should be what appears in the dropdown
If you are on Windows 10 the path to add the new theme is :
C:\Users\NAME-OF-COMPUTER\AppData\Roaming\Notepad++\themes
stylers.xml is located one director/ folder above the themes :
Just as a complement to the other answers, if you made the changes on another theme than the default theme (stylers.xml) then your changes are saved to
%APPDATA%\Notepad++\themes\TheThemeYouModified.xml.
For example, if you modified the choco theme, then look for the %APPDATA%\Notepad++\themes\choco.xml.
You will also find a choco.xml in the C:\Program Files (x86)\Notepad++\themes but this one is not where your changes are saved.
I tried Rbastardo answer, but even when I check "Don't use %APPDATA%....." when installing Notepad++, the changes are still saved in %APPDATA%.
In case this helps someone in the future, if you installed Notepad++ via Scoop then look for your themes directory here:
D:\Users\yourusername\scoop\persist\notepadplusplus\themes

Resources