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

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

Related

How to auto-reload current file in sublime text

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

How do you make Sublime Text 3 open a file in a new tab instead of opening it in the current tab?

When I click the file I want to open in Sublime, it is replacing the current tab I have open. It used to open it in a new tab.
This is because you were only previewing the previous file. If you click on a file once in the sidebar, by default it opens in preview mode. Clicking another file will open it in preview mode, in the same tab. You can disable this behavior by double-clicking the file in the sidebar, by beginning to edit the file, or via the user settings: select Preferences -> Settings-User and add
"preview_on_click": false,
then save the file. With this new behavior, you will need to double-click on a file in the sidebar to open it, and it will not close if you double-click another file.
Preferences -> Settings-User -> "open_files_in_new_window": false
Open Registry Editor (The easiest way to do this in all versions of Windows is to open the Run dialog box via WIN+R, and enter regedit)
go to :
Computer\HKEY_CLASSES_ROOT\Applications\sublime_text.exe\shell\open\command
change it from :
"C:\Program Files\Sublime Text 3\sublime_text.exe" "%1"
to :
"C:\Program Files\Sublime Text 3\sublime_text.exe" -n "%1"
You can use a simple python script to get files to open in a new tab with a single click.
import sublime
import sublime_plugin
import os
class NoPreview(sublime_plugin.EventListener):
def on_load(self, view):
if (os.path.exists(view.file_name())):
view.run_command('save')
Save this script with a .py extension in your sublime packages directory.
(Usually ~/.config/sublime-text-3/Packages/User in Linux)
Note: Make sure "preview_on_click" is set to true in Preferences > Settings, otherwise this will not work.
You can simply go to preferences/settings/preferences.sublime_setting.
Under this, after font-size(array), paste this "preview_on_click": false.
And you are done!
Note: After this, you have to double click to open any file.
On single click you preview the files. You can double click on the file to open them in a new tab.
You must be having "show tabs" unchecked under the VIEW tab. Check it and you can open a file with a double click.

Is it possible to pin the project into folder panel in Sublime Text 3?

Updated: Probably, my question doesn't make sense. Could you please close it?
I am quite new to Sublime Text. I open my project by dragging and dropping my project folder into Sublime Text.
However, when I quit Sublime Text, and reopen it, my project is gone. I need to drag and drop again. Is it possible to pin my project into Sublime Text, so the next time when I open, my project is still there?
Thanks.
Note: I am using Sublime Text 3
You can save your project on disk: Project > Save Project As... When you open your editor next time it should open automatically. If not, go to Project > Open recent.
Documentation: https://www.sublimetext.com/docs/3/projects.html
Set "hot_exit": true in preferences
Exiting the application with hot_exit enabled will cause it to close
immediately without prompting. Unsaved modifications and open files will
be preserved and restored when next starting.
Closing a window with an associated project will also close the window
without prompting, preserving unsaved changes in the workspace file
alongside the project.

Sublime Text strange behaviour

I have a strange behaviour on my Sublime3 editor. I just started using it, having not much experience with.
I add some code like
use Kakuki\Reports\Models\Campaign;
And on save the code is kicked out.
Apparently it seems that PHPTools package caused this issue. How do I configure this Package?
Try disabling PSR mode via the User Preferences.
From the "Preferences" menu, choose "Package Settings", "PHPTools" and then "Settings - User".
Paste { "psr":"False" } into that file. (If that file is not already empty, just add , "psr" : "False" to the last line in that file. )
Save the preferences file and create a new "New View Into File".
Any time you install a new Sublime Text package, it's a good idea to take a look at its configurable options. You can do this from the "Preferences" menu, and then "Package Settings", the name of your package and finally "Settings - Default". Most package developers will pre-populate this file with all of the available options and comments about what they do. Note that you shouldn't edit this file (it will be overwritten every time the package updates), but you can use this to inform your user settings as above.

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