[visual-studio-code] Cannot edit in read-only editor VS Code

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.

This question is related to visual-studio-code

The answer is


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.


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.

  1. just go to terminal tab and select powershell or default terminal
  2. type python Nameoffile.py
  3. you will be able to input

You are in the "Output" tab instead of the Terminal. The output tab is actually only for you to read from.

enter image description here

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).

enter image description here


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)

enter image description here

my solution was to replace cygwin's gdb and g ++ with mingw64's.

then the input output are normal

enter image description here 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.


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).


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


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:


Had the same problem. Here’s what I did & it got me the results I wanted.

  1. Go to the Terminal of Visual studio code.
  2. Cd to the directory of the file that has the code you wrote and ran. Let's call the program " xx.cpp "
  3. Type g++ xx.cpp -o a.out (creates an executable)
  4. To run your program, type ./a.out

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 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'

enter image description here

enter image description here

enter image description here


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:

  1. Go to extensions (Ctrl + Shift + X)
  2. Find code runner and click on the settings icon on bottom right of the code runner
  3. Click configure extensions settings
  4. Find code_runner: Run in terminal
  5. Check "Whether to run code in terminal"

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.