Reputation: 667
It is difficult to describe with 1 or 2 words so here I will give a use case:
Note: UserB and UserC may need to make structural changes to the text file also sometimes, so forbidding them write/modify access at file-system/file-share levels is not an option. It has to be a conscious decision when structural editing is needed (e.g. a user opens the file with a special flag to vim or presses an "unlock" key sequence after opening the file).
Upvotes: 1
Views: 590
Reputation: 6637
The workflow you describe suggests that UserB and UserC don't actually need to save the file (unless they're doing structural edits), they just usually need it open so they can mark quick line items done as they complete them. (If they actually do need their edits saved, you'd need to supply a lot more detail in your use case, and then I'd agree with the commenters anyway that you need a more robust solution.)
The easiest way to do this is to mark the file as readonly in the filesystem. On Windows, you can do this with attrib +r filename.txt
. I forget whether there's an equivalent attribute in Unix-style systems, or if you instead have to actually remove write permissions completely.
When UserB or UserC need to save their changes for structural edits, they do :w!
instead of the usual :w
to save the file. This forces vim to ignore the readonly attribute and save the file anyway.
Upvotes: 1