Communities

Writing
Writing
Codidact Meta
Codidact Meta
The Great Outdoors
The Great Outdoors
Photography & Video
Photography & Video
Scientific Speculation
Scientific Speculation
Cooking
Cooking
Electrical Engineering
Electrical Engineering
Judaism
Judaism
Languages & Linguistics
Languages & Linguistics
Software Development
Software Development
Mathematics
Mathematics
Christianity
Christianity
Code Golf
Code Golf
Music
Music
Physics
Physics
Linux Systems
Linux Systems
Power Users
Power Users
Tabletop RPGs
Tabletop RPGs
Community Proposals
Community Proposals
tag:snake search within a tag
answers:0 unanswered questions
user:xxxx search by author id
score:0.5 posts with 0.5+ score
"snake oil" exact phrase
votes:4 posts with 4+ votes
created:<1w created < 1 week ago
post_type:xxxx type of post
Search help
Notifications
Mark all as read See all your notifications »
Q&A

Post History

50%
+0 −0
Q&A Text Editors. Suggesting & Tracking Changes to Plain-Text Documents

If it is about text changes, I'd use diff files (in particular the “unified diff” format which also many version control systems use), with a caveat mentioned below. You can create the diff file by...

posted 3y ago by celtschk‭

Answer
#1: Initial revision by user avatar celtschk‭ · 2021-05-21T05:28:19Z (almost 3 years ago)
If it is about text changes, I'd use diff files (in particular the “unified diff” format which also many version control systems use), with a caveat mentioned below. You can create the diff file by keeping the unedited file besides the edited file, and then use the `diff` utility, redirecting the output to another file.

Note however that `diff` works line oriented; therefore it doesn't deal well with reflowing text.

As an example, consider the following text in old.txt:
```
This is sample text.
This exists purely for demonstration issues.
In particular, for demonstration of diff.
It has no other purpose.
This file has 6 lines.
This is the last line.
```
And the edited text in new.txt reads:
```
This is some sample text.
Which has been changed.
This exists purely for demonstration issues.
It has no other purpose.
This file has 6 lines.
This is the last line.
```
Then `diff -u old.txt new.txt` gives
```
--- old.txt	2021-05-21 07:14:11.805978537 +0200
+++ new.txt	2021-05-21 07:16:07.073068543 +0200
@@ -1,6 +1,6 @@
-This is sample text.
+This is some sample text.
+Which has been changed.
 This exists purely for demonstration issues.
-In particular, for demonstration of diff.
 It has no other purpose.
 This file has 6 lines.
 This is the last line.
```
This in my opinion makes it easy to track changes.

However, it doesn't work well with reflow. Imagine you've reflowed the text before making a single change, like this:
```
This is sample text. This exists purely for demonstration issues. In
particular, for demonstration of diff. It has no other purpose. This
file has 3 lines. This is the last line.
```
Now the diff reads:
```
--- old.txt	2021-05-21 07:14:11.805978537 +0200
+++ new2.txt	2021-05-21 07:21:02.572795731 +0200
@@ -1,6 +1,3 @@
-This is sample text.
-This exists purely for demonstration issues.
-In particular, for demonstration of diff.
-It has no other purpose.
-This file has 6 lines.
-This is the last line.
+This is sample text. This exists purely for demonstration issues. In
+particular, for demonstration of diff. It has no other purpose. This
+file has 3 lines. This is the last line.
```
This basically is the complete original text followed by the complete reflowed text. So it's not easy to see the content change in that way. Therefore if such reflowing is common, using `diff` may not be the best way.