Reputation: 11334
I've written a simple Sublime Text 3 plugin which let me open a log file with a keybord shortcut :
class OpenFilesCommand(sublime_plugin.TextCommand):
def run(self, edit, var_str):
str_date = datetime.datetime.strftime(datetime.datetime.now(),'%Y-%m-%d')
path_file = '/home/user/logs/web_'+str_date+'.log')
if os.path.isfile(path_file):
self.view.window().open_file(path_file)
else:
sublime.error_message("The file does not exist.")
My problem is : if the log file is already open in Sublime, when I use shortcut the file content is not reload from file content.
Do you know a way to refresh Sublime file content from hard disk file content ?
Upvotes: 2
Views: 240
Reputation: 16105
If the file is already open, and you want Sublime Text to refresh the view from the file, you can use the revert
command to reload it from the disk.
self.view.window().run_command('revert')
Upvotes: 2