1

It is difficult to describe with 1 or 2 words so here I will give a use case:

  1. UserA creates a text file which acts as a fillable form/checklist
  2. UserA saves the file to a shared repository
  3. UserB and UserC open the file and fill the form/checklist as they do their work
  4. Changes to fields (ideally) or to the whole file are ignored if file saved by accident

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).

4
  • For a moment I thought you were describing something similar to this demo from 1968. Commented Mar 19, 2012 at 4:33
  • 1
    Revision control systems like CVS, SVN or Git may work in this case. Also try Gobby, a collaborative editing software. Commented Mar 19, 2012 at 5:02
  • 3
    This doesn't seem to me to be particularly suitable for "plain text editor" work. You should make or use a specialised tool for it. Commented Mar 19, 2012 at 6:39
  • I agree with the above comments and we do use Git already, for tracking those structural edits. Why the question relates to Vim is because our work does pretty much everything via ssh on remote servers and vim is the most used tool. Commented Mar 20, 2012 at 7:09

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.