is there a way to highlight the rows that have changed since last save and not yet stored (for example, near the line number)?
Hightlight changed row
Change Tracker - highlights changes
Highlighting lines changed from the last commit
No, but it could definitely but done very easily with a plugin. Iāll try to make one for you.
Hereās your plugin. Just go to Tools > New Plugin. Paste this into the new file. Save the file as whatever you want (I called it HighlightUnsaved.py), just make sure you save it in your User folder in Sublime Textās Packages directory (should be the default when you press save as but Iām not positive).
[code]import sublime, sublime_plugin
class ClearChangesCommand(sublime_plugin.EventListener):
def on_post_save(self, view):
view.erase_regions(āunsavedā)
class HighlightUnsavedCommand(sublime_plugin.EventListener):
def on_modified(self, view):
unsaved = view.get_regions(āunsavedā) + [view.line(s) for s in view.sel()]
view.add_regions(āunsavedā, unsaved, āunsavedā, ādotā, sublime.HIDDEN | sublime.PERSISTENT)[/code]
wow fantastic and fast, thanks!
There is also a way that when you undo a change in a row, the system removes the marker?
Thanks
Simon
This took a bit of work but here it is:
[code]import sublime, sublime_plugin
class ClearChangesCommand(sublime_plugin.EventListener):
def on_post_save(self, view):
view.erase_regions(āunsavedā)
class HighlightUnsavedCommand(sublime_plugin.EventListener):
def on_modified(self, view):
unsaved = view.get_regions('unsaved') + [view.line(s) for s in view.sel()]
with open(view.file_name(), 'r') as f:
read_data = f.read()
for sel in view.sel():
print view.line(sel)
if read_data[view.line(sel).begin():view.line(sel).end()] == view.substr(view.line(sel)):
unsaved:] = [x for x in unsaved if x != view.line(sel)]
view.add_regions("unsaved", unsaved, "mark", "dot", sublime.HIDDEN | sublime.PERSISTENT)[/code]
Same thing as before: save as a plugin in User directory (or you can just overwrite the last plugin).
Interesting approach.
How I understand the API that is not possible to intercept an event before the user changes the contents of a row to save its state and compare it after each change to see if it was restored to its original state.
An alternative might be to save all rows in a buffer when the file is loaded (but consume a lot of memory) and use that for comparison instead of opening the original file for each change.
The problem with the comparison between the original file or a buffer is that the addition of a line means that all subsequent lines will appear to be changed.
Anyway thanks for this code!
Iām new to Python/Plugin Development so there is probably a better way to make the plugin. This way was the first way that I thought of. The addition of new lines will cause trouble to the pluginā¦ and I canāt seem to think of a workaround that wouldnāt take a lot of memory. (I didnāt realize youād be judging my code so much )
I just hope I helped.
Hi
A long time ago, I changed this plugin to work with sublime text 2 because it stopped working.
When I switched to Sublime text 3, I fixed it again.
Now I just uploaded it to github to everyone use.
Of course all credits go to C0D312
Sublime text 2 branch: github.com/JuDelCo/Highlight-Changes
Sublime text 3 branch: github.com/JuDelCo/Highlight-Ch ā¦ ime-text-3
Example (screenshot):
EDIT: Okay, i just noticed the thread is in general forum. Maybe thereās better in Plugin Announcements or Plugin Development ? Nevermindā¦ xD
Thanks
Possible to put line highlights?