I am using Visual Studio Code V 1.31.1. I used an input function but I can't write an input in output panel it shows this error
Cannot edit in read-only editor.
Please help me solve this problem.
I am using Visual Studio Code V 1.31.1. I used an input function but I can't write an input in output panel it shows this error
Cannot edit in read-only editor.
Please help me solve this problem.
For Mac users, it is Code > Preference > Settings.
whether to run code in integrated terminal
and got exactly one to check
Commented
Sep 1, 2019 at 8:43
If you can't find where to find code runner as said in Ali NoumSali Traore's answer, here's what you got to do:
I received this error during a code compare with previous version and it wasn't letting me edit the current version in the Right-Window. Unrelated to what I suspect OP's issue but this was the first thread that came up for my search and the error was the same. anyway...
My issue was that the particular file was 'Staged' in my source control at the time. This appears to restrict editing by opening an 'index' version for the compare.
Solution: Un-stage the file, and reopen the comparative window.
You are in the "Output" tab instead of the Terminal. The output tab is actually only for you to read from.
Press F5
to begin Debugging
and it'll bring you into the Terminal tab.
The terminal is interactive, so you can read output AND type back. It is indeed a console prompt/ terminal (hence its name).
The easiest way to fix this was to press (CTRL) and (,) in VS Code to open Settings.
After that, on the search bar search for code runner, then scroll down and search for Run In Terminal and check that box as highlighted in the below image:
I was experiencing this issue while using the SFTP extension in VSCode. In this case, all you have to do is right-click somewhere in the file and select 'edit in local'
My issue was different than OP. I was trying to compare the file changes between commits. When I see some issue in diff view, I wasn't able to edit the file getting same message as OP. To fix that, instead of opening the file in diff view. Right-click on it and choose Open Changes > Open Previous Changes with Working File. This view will let you edit while comparing. Hope this helps.
Had the same problem. Here’s what I did & it got me the results I wanted.
xx.cpp
"g++ xx.cpp -o a.out
(creates an executable)./a.out
I received the same error like @jgritten. Just like the comment before me by @jgritten, I 'unstaged' and reopened vscode and the files. Now I 'staged' it again. The error "Cannot edit in read-only editor" didnt come.
Hope this reassures anyone who might have similar error after staging the file using git in vscode.
When you run Debug Cell
, you may notice that you sometimes can't edit after stopping the debug process.
As silly as it sounds, check your open file tabs.
The debugger appears to open a read-only copy that is separate from your working file w/ the same name.
If your code takes input from a user you can't just use output tab. You have to use any terminal as Jordan Stefanelli have said.
I had the Cannot edit in read-only editor
error when trying to edit code after stopping the debug mode (for 2-3 minutes after pressing Shift+F5
).
Turns out the default Node version (v9.11.1) wasn't exiting gracefully, leaving VScode stuck on read-only.
Simply adding "runtimeVersion": "12.4.0"
to my launch.json file fixed it.
alternatively, change your default Node version to the latest stable version (you can see the current version on the DEBUG CONSOLE
when starting debug mode).
As the @Jordan Stefanelli answer: If you encounter the same problem as me that the integrated Terminal cannot read input from user as below hanging (env. Windows 10)
my solution was to replace cygwin's gdb and g ++ with mingw64's.
then the input output are normal
also you can enable "external console" option to solve it:)
you can change it by enabling "externalConsole":true in the launch.json then you will get a pop up console window that you can type in.
Short Answer: After installing "Code Runner" extension, you just have to right-click the selected part of code you wish to execute and see it in the Output Tab.
Click on the file and hover on Preferences. there you will find the first option as Settings and click on that. There search run code. and scroll and find the option code runner: Run in Terminal. now check the option below it
I had the same problem, even though i enable the code runner to true, i was not still able to get my vsc terminal run. The quick fix was that mentioned by @Jordan Stefanelli. I add to my setting.json in the launch section "externalConsole":true,
"launch": {
"externalConsole":true,
"configurations": [],
"compounds": []
}
Here's the easy way: Above your error "cannot edit in read-only editor" there will be a path to your cpp code file, it might look something like this if you are running on Linux:
cd "/home/jacksparrow/Documents/projects/" && g++ exams.cpp -o exams && "/home/jacksparrow/Documents/projects/"exams
so all you have to do is "copy(ctrl+shift+C) that path address and paste(ctrl+shift+V) it in the terminal window and press enter" right next to your output and debug console window. This worked for me, hope it does for you too.
In VS Code, install code runner. When running your file please specify how you want to run the file, in the output window or terminal. For a better experience make sure you have selected the terminal.
I installed the https://marketplace.visualstudio.com/items?itemName=formulahendry.code-runner and it started working for me.
if you are searcing for this in 2022 so you only need to RIGHT CLICK and click on EDIT local
I ran into the problem when following Prag Programmer's Phoenix Live View tutorial. The setup section of the tutorial says to do this:
Simple Ruby ERB extension for toggling <%= %> EEx tags using the custom keybindings you'll find in the vscode/keybindings.json file of the code bundle. To add these keybindings, use the "Preferences: Open Keyboard Shortcuts (JSON)" command and paste the contents of keybindings.json into that file.
When I clicked on View > Command Palette
then entered Preferences: Open Keyboard Shortcuts (JSON)
that opened up a Default keybindings
file:
[
{ "key": "escape escape", "command": "workbench.action.exitZenMode",
"when": "inZenMode" },
{ "key": "shift+escape", "command": "closeReferenceSearch",
"when": "inReferenceSearchEditor && !config.editor.stablePeek" },
{ "key": "escape", "command": "closeReferenceSearch",
"when": "inReferenceSearchEditor && !config.editor.stablePeek" },
{ "key": "escape", "command": "editor.closeTestPeek",
"when": "testing.isInPeek && !config.editor.stablePeek || testing.isPeekVisible && !config.editor.stablePeek" },
{ "key": "shift+escape", "command": "cancelSelection",
...
...
...
But, I can't paste anything into that file because I get the message:
Cannot edit in read only editor.
I checked out the VS Code manual on Advanced Customization, which says:
Unfortunately, the icon for the Keyboard Shortcuts editor, the one with the green rectangle around it, was nowhere to be found. I was able to get that icon to display using the menu bar:
Code > Preferences > Keyboard Shortcuts
That brought up a page that looked like this:
If you look closely, up in the right hand corner is the icon for the Keyboard Shortcuts editor. I clicked on the icon, and that opened up a keybindings.json
file, which looked like this:
// Place your key bindings in this file to override the defaults
[
]
...and I was copied the recommended key bindings:
{
"key": "shift+cmd+,",
"command": "erb.toggleTags",
"when": "editorTextFocus && editorLangId == phoenix-heex"
},
{
"key": "shift+cmd+,",
"command": "erb.toggleTags",
"when": "editorTextFocus && editorLangId == elixir"
}
and pasted them into that file, giving me this:
// Place your key bindings in this file to override the defaults
[
{
"key": "shift+cmd+,",
"command": "erb.toggleTags",
"when": "editorTextFocus && editorLangId == phoenix-heex"
},
{
"key": "shift+cmd+,",
"command": "erb.toggleTags",
"when": "editorTextFocus && editorLangId == elixir"
}
]
This solved the issue for me:
Go to File > Open Folder... and open your project folder again.
Had similar issue, it took me a while to figure it out but in my case I basically clicked on the wrong thing.
In the Source Control tab of VSCode (third icon, selected in left panel, see screenshot), I had some changes:
Changes
folder).Outgoing
folder, in Add..
folder with green and red icons).I kept trying to work by clicking in the second ones (with the green and red icons) and trying to modify that file but that one is for reference in VSCode.
As soon as I clicked the first ones with the name of the file in the Changes
folder I was back on editing mode 👍🏼
Hope this was helpful, hope you guys have a great day!