type: run code and scroll down until you see code-runner: Run in terminal, There will be multiple options called "code-runner". In that you can find the option mentioned below.
just check "Whether to run code in integrated terminal" and
restart vscode.
For Mac users, it is Code > Preference > Settings.
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.
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.
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.
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'
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).
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,
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.
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.
In my case file encoding types was in utf-8 with bom
By opening in any text editor (I have used visual studio code but you can use any other text editor) and save with utf-8 will open file in edit mode and hit the debugger as well