Smart comments - update on save

PatrickTaylorEdwards 11 years ago updated by Jacob Gardner 11 years ago 1

Perhaps this already exists, but I would love my comments to be updated each time I save a file. For example, I have a comment at the start of all my JavaScript files and when I save the file I would like my comment to update, automatically. The comment includes information such as 'Modified By', 'Date last edited', and the file name. A plugin or feature to add a default comment with this information, in my set format, would be really useful; I imagine it would work in the same way as default email signatures - but with variables.

This can already implemented via  plugin using


There's no reason for this specific functionality to be a part of the core API.

Would look similar to this (haven't tested):

import sublime_plugin

import re

class AutoUpdaterThing(sublime_plugin.EventListener):

on_pre_save(self, view):

r = self.view.find('regex_pattern_here', 0)

self.view.replace(edit, r, 'whatever you want dynamically inserted'