3

I use SVN, but SVN extension is not support "lock-modify-unlock".

VS Code lets me edit files that are not locked (and thus read-only) and will only ask for confirmation when saving.

I want VS Code to stop me from editing so that I remember to lock the file before changing anything.

Joachim Sauer
  • 302,674
  • 57
  • 556
  • 614
  • In vscode, read-only files can be modified, and a confirm window appears when saving. I don't want to modify the contents if it's a read-only file. – HaJong Jeong Nov 19 '20 at 14:29
  • 2
    Yes. For example, Notepad++ cannot be modified for read-only files. I wish vscode were, too. – HaJong Jeong Nov 19 '20 at 14:33
  • thank you. I have poor english. so it's hard to make an easy sentence. – HaJong Jeong Nov 19 '20 at 14:38
  • @Joachim-Sauer I'm really not getting why you're chiming in here, when you obviously don't get the question. It is really annoying and not helpful. – Frank Puck Feb 16 '22 at 17:10
  • @FrankPuck: my last interaction with this question was in Nov. 2020 and I don't remember it at all. If there were comments of mine here they have since been removed (moderator? I don't know). My edit suggests that I tried to understand what OP is asking in order to improve the question. Maybe I wasn't as nice as I could have been, but let's assume good intentions, okay? If you look at the revision history of this question you'll see that the initial version was very hard to understand. – Joachim Sauer Feb 16 '22 at 22:09

1 Answers1

0

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:

Read-only

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.
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250