I edited a file in Sublime without saving it. Now I want to reload the saved version with discarding my changes. How is that possible? Do I really have to close the tab without saving and open it again manually or is there some hotkey to replace the shown version by the saved one?
In Sublime 3: File -> Revert File
You can also bind a hotkey in Preferences -> Key Bindings - User
{
"keys": ["f10"],
"command": "revert"
}
Related
I recently upgraded the version, there is a need to transplant function, but this feature I do not know because it is installed what plug-in? So now need to manually add, I know you can use shortcut keys binding, but my shortcut keys are occupied, and if you continue to set up but it is not convenient to use.
{ "keys": ["ctrl+*+*"], "command": "save_all" }
demo
needs improvement
Find the Default.sublime-package file,
rename Default.sublime-package to a zip file and unzip.
There we find the file Tab Context.sublime-menu and Context.sublime-menu
Add {"command": "save_all", "caption": "Save All"},
The effect is as follows:
Tab Context
Context
Sometimes I would like to modify files in another text editor and switch back, but Sublime Text 3 wouldn't reload the current file that I edited before.
How do I get it to reload the file automatically?
There's a setting to control whether you get to see a prompt, but otherwise Sublime Text reloads the file automatically by default.
See the setting in Preferences.sublime-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": false
I believe AutoReload should do the trick.
You can also reload file manually using menu File->Revert File
If the file is changed on disk, and is open in Sublime, the default behavior is a dialog window that prompts to see if you want to reload the file.
If you have previously selected "Ignore All" when prompted with that dialog for that particular file, then Sublime's behavior for that file will be changed. The file view setting will be changed from True to False for reload_file_on_change.[1]
You can get the current file view setting (for whichever file is open in your view) by typing this in the console[2]:
view.settings().get('reload_file_on_change')
And can you set the current file view setting back to True with this[3]:
view.settings().set('reload_file_on_change', True)
I searched ["ignore all" sublime reload save] to find this question/comment from thundt and the answer from bschaaf in the Sublime Forum: Ignore All when unsaved changes and file changed on disk is not helpful!
Found via Sublime Text Docs > Settings > Troubleshooting
Found via Sublime Text API Reference > Settings > .set
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
Is there any shortcut to delete the currently opened file in Sublime 3?
I have installed the SideBarEnhancements, but it is a lot of work to right click on a file, select delete, confirm the popup and then again close the file and the popup, because the file has been deleted and I have some unsaved changes.
The functions name to delete the selected file from the sidebar is named "side_bar_delete", so if you have SideBarEnhancements installed you can use this function. So my version for example is:
[
{"keys": ["super+alt+backspace"], "command": "side_bar_delete"}
]
Paste it in the general user.sublime-keymap file.
This plugin will delete the file and close the buffer, and you could bind the command to a key.
Note however there's a potential conflict with the SideBarEnhancements delete command, see the workaround described in the readme.
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,
}