I want VS Code to stop me from editing so that I remember to lock the file before changing anything.
This should be supported with the new (May 2023) "VSCode 1.79 Workbench Readonly mode"
In some development scenarios, it can be helpful to explicitly mark some of a workspace's folders or files as read-only.
For example, if the folder or file contents is being managed by a different process (such as the node_modules folder that is managed by Node.js package manager), marking them are read-only can avoid inadvertent changes.
For this use case, there are new settings to mark file paths as read-only in the Explorer and in text and notebook editors:
files.readonlyInclude
- Paths or glob patterns to make a file read-only if matching.
files.readonlyExclude
- Paths or glob patterns to skip files from being read-only when they match files.readonlyInclude
.
files.readonlyFromPermissions
- Whether a file that has no write-permissions on disk should be read-only.
You can now see clear "read-only" markers:

For more ad-hoc toggling of the read-only mode, there are new commands to change the mode for the current session only, overruling your setting configurations:
Set Active Editor Readonly in Session
- Mark active editor read-only.
Set Active Editor Writeable in Session
- Mark active editor writeable.
Toggle Active Editor Readonly in Session
- Toggle between read-only and writeable.
Reset Active Editor Readonly in Session
- Reset the session state.