vscode
vscode copied to clipboard
Add read-only mode
- VSCode Version: 0.10.11
- OS Version: Fedora 23, 64bit
Details:
- Please add read-only mode and its keyboard shortcut.
- It should be a switch. When turned on, opening new files will be in read-only mode.
- It should be persistent across restarts.
This feature should be very useful for code reviewing. And I think it's not hard to implement.
Thank you,
I agree that a read-only mode that can be toggled would be super useful, though I would prefer it to be a temporary state, and apply just to the current open document. So maybe it could work as haibison says when applied at a folder level, but be a temporary state when applied at an individual file level?
For me, something like an "editor.action.ToggleReadOnly" shortcut would be great. That would disable edits, and prevent saving of the currently open file. Ideally it would have some sort of obvious visual indicator as well, so if it's toggled accidentally the user will understand why they can't make changes.
Thank you @coe-jeubanks
I often review code, so I think making that option persistent across restarts is useful. But you and other people might like it as a temporary switch. So my idea to dev team is maybe we could have an option to switch between "persistent" and "temporary" modes?
One scenario is when opening multiple files at a time: read-only option should be "remembered", or the code reviewer will have to manually mark those files read only one by one. It sounds simple, but I used to work with Geany -- which has read only mode. When doing so (opening multiple files, then switching to each tab to mark the file read-only), and doing so every day, it feels that a switch would help me a lot.
So when you're in "code review mode," you don't need to have any other files open for editing at the same time (taking notes, etc.)? That was why I thought a read-only at the folder level would work for you--you could put all of your files you are reviewing into one folder, and open that folder in Code, marking it (perhaps permanently) read-only. Then you'd still be able to create and save documents into other folders at the same time you are reviewing the read-only files. Below is a mock-up of what I mean. In my example, all of the folders except Notes are toggled to read-only, and you could individually set files in Notes temporarily to read-only if you want to review them. Yet you would still retain the ability to create and update other files in Notes.

My typical use for read-only is when I'm editing one file and need to have a second one open for comparison or reference, but I don't want to inadvertently make any changes to the reference file. I used to use UltraEdit, which has a toggle-able read-only option for an open file.
I do hope they can create an enhancement that meets both of our needs!
I also would like option of setting read-only for an open file to prevent changes.
fyi @bpasero
Would really like this or something similar to it. eg. https://github.com/Microsoft/vscode/issues/12227
A command line argument to optionally open each file(s) as read only would be nice.
Throwing my support in for a command line option to open a file as read only. Would be really handy for my workflow
I would also like this on a file level and persistent. Alternatively, it could be a temporary setting that I could set on an open file.
I want to set it on babel transpiled output files. I sometimes open these to check where errors in the browser occurred, but only want to edit the original source files. This option would stop me from forgetting and accidentally editing the transpiled output.
Other issues that requests this feature #33823 #17670
The editor has an option readOnly that would need to be exercised by the workbench => removing editor label.
This would be very helpful
I too would like to see a command line option to open a file as read-only:
My use case:
I use file manager tools (e.g. Total Commander) to navigate through source files and have a need for opening files for read-only to just view the code without accidentally changing the code.
I previously used Notepad++ for editing and viewing source code, and this worked perfectly because Notepad++ have a command line option to open the file as read-only.
I have since switched to VS Code as an editor, and I really miss the option to call VS Code from the file manager and have VS Code open the file as read-only.
I prefer to use VS Code instead of Notepad++ as I'm working on different platforms and can have VS Code on all my platforms, but the missing read-only option in VS Code forces me to still have Notepad++ as my code viewer when I'm on Windows.
When will this feature be available?
Another use-case: when viewing application log files, I do not wish to accidentally change a file.
I need read-only mode for code-workspace's root-folders.
opening files (or folders) as read-only would be a great addition I would get a lot of use out of.
Would love to see this. I'm currently using vscode for debugging and vim for editing and sometimes I get my alt-tabs mixed up and end up editing files in vscode accidentally.
I remember long long ago Visual Studio had this. You could simply right-mouse click in the editor and there was an option to set the file to read-only. Actually, it didn't even set the file on disk to read-only, it was just in the editor.
Would love to see this in Visual Studio Code.
This could be useful for when the user opens a system file via go to definition or the debugger, e.g., a file in an installed Ruby gem.
Any updates? Would love this ability.
I found this request while trying to figure out how to mark a file read-only in the editor. I had two files open, one for reference and one that I was editing. Naturally I wound up editing the reference file and not the one I intended. It would be very helpful to be able to open a file, right-click and set a read-only/no-edit option for the open document.
One simple scenario: In my node app code base, I navigate to node_module files a lot to read source code, but more than a few times that I found changing the files with mistaken finger typing. IntelliJ would make an alert for this. I'd like this feature available in vscode. Thank you very much.
I need readonly since I'm viewing a file's hexdump on VSCode but have to close out everytime I rerun it since two programs can't be writing to the same file.
Any updates on this feature?
I use Go language, and sometimes I would like to take a look at those built-in libraries. I need this feature to prevent modification on them. Any work on this will be appreciated.
I have looked far and wide for a solution to this! From a teacher standpoint, this feature is vital when demonstrating code on-screen with a range of 20-30 in-class students. Together with Visual Studio's Live Share, this feature is an absolute necessity!
+1 upvote for in-class setting
I would love this feature. I would want it to detect Unix file permissions and prevent the user from accidentally spending time editing files they don't have write permission for.
Are we there yet?
Is there any new state of update here? I'm using a source control in the way of lock/edit and commit. In this way of source controlling it is very important to recognize which files are read-only to lock them up befor change anything.
At the moment I do not need to lock them to have the possibility to change something. Result is, that somtime this ends up into a merge procedure, which I actually try to prevent by the kind of source control i use. I would be very pleased if this feature would be implemented.
For me, it mainly relates to my build output... I often peek at those files and it is all to easy to start editing the files, save, do a build, and overwrite my changes. From my perspective, it would be great to be able to list a file match pattern to treat as read only in the editor, e.g. dist-*/**
Adding a partial answer, see top answer here: https://stackoverflow.com/questions/30140112/how-do-i-hide-certain-files-from-the-sidebar-in-visual-studio-code files: exclude
Above is not a perfect solution but it does make me think hard if I want to open a built file, which is half the battle. But, it's disconcerting to not be able to see my built files easily.