Lỗi cannot edit in read only editor vscode

You can also open the settings screen by pressing Ctrl +

Copied!

# Windows taskkill /F /IM code.exe

4 on Windows and Linux or

Copied!

# Windows taskkill /F /IM code.exe

5 +

Copied!

# Windows taskkill /F /IM code.exe

4 on macOS.

  1. Type Code Runner terminal and tick the Code-runner: Run in terminal checkbox.

Lỗi cannot edit in read only editor vscode

Make sure to check the Code-runner: Run in terminal checkbox as shown in the code sample.

Alternatively, you can enable the setting directly in your settings.json file.

  1. Press Ctrl + Shift + P (or Command + Shift + P on macOS).

Note: you can also press

Copied!

# Windows taskkill /F /IM code.exe

2 to open the Command Palette.

  1. Type user settings json.
  2. Click on Preferences: Open User Settings (JSON)

Lỗi cannot edit in read only editor vscode

  1. Add the following line to your settings.json file.

Copied!

{ "code-runner.runInTerminal": true }

Lỗi cannot edit in read only editor vscode

Either approach works.

After you set the setting, restart VS Code:

  1. Press Ctrl + Shift + P (or Command + Shift + P on macOS).

Note: you can also press

Copied!

# Windows taskkill /F /IM code.exe

2 to open the Command Palette.

  1. Type reload window and select Developer: Reload Window.

Lỗi cannot edit in read only editor vscode

Try to run your code after having enabled the setting.

You can click on the arrow in the top right corner to run your code in the terminal.

Lỗi cannot edit in read only editor vscode

You can also right-click in the editor window and select Run Code.

Lỗi cannot edit in read only editor vscode

You can also use the Command Palette:

  1. Press:
  2. Ctrl + Shift + P on Windows and Linux
  3. Command + Shift + P on macOS

Note: you can also press

Copied!

# Windows taskkill /F /IM code.exe

2 to open the Command Palette.

  1. Type Run code and select the command.

Lỗi cannot edit in read only editor vscode

Using the Stop Code Run command in the Output tab

If your code is stuck in the Output tab, right-click and select Stop Code Run.

Lỗi cannot edit in read only editor vscode

You can also stop the Code Runner process by using a keyboard shortcut:

  • Ctrl + `settings.json`0 + `settings.json`1 on Windows and Linux
  • Copied!

    Windows

    taskkill /F /IM code.exe

    5 + `settings.json`3 + `settings.json`1 on macOS

Restart all VS Code instances if the error persists

If the error persists, you might have a VS Code process that runs in the background.

On Windows, open CMD and run the following command to stop all VS Code processes.

Copied!

# Windows taskkill /F /IM code.exe

On macOS and Linux, run the following command to stop all VS Code processes.

Copied!

# macOS and Linux killall code

If the `settings.json`5 command doesn't succeed on macOS or Linux, try issuing the following command instead.

Copied!

ps -ef | grep code | awk {'print $2'} | xargs kill -9

Once you run the command and stop all VS Code processes, restart the IDE and try to run your code.

Closing the terminal properly once you're done

Note that when you click on the `settings.json`6 icon at the top right corner of the terminal, you don't actually close it.

Lỗi cannot edit in read only editor vscode

If you click on the `settings.json`6 icon, the terminal still runs in the background.

You need to click on the trash bin icon to close it and stop the process.

Trying to edit your default settings.json file

You can't edit the default settings.json file because it is in read-only mode.

Lỗi cannot edit in read only editor vscode

Instead, you should open the global user's settings.json file which is editable.

  1. Press Ctrl + Shift + P (or Command + Shift + P on macOS).

Note: you can also press

Copied!

# Windows taskkill /F /IM code.exe

2 to open the Command Palette.

  1. Type user settings json.
  2. Click on Preferences: Open User Settings (JSON)

Lỗi cannot edit in read only editor vscode

Now you can edit the non-default version of the settings.json file.

If you want to read more about the different ways to open and edit`settings.json`, check out my other article:

  • How to open settings.json in VS Code [6 Ways]

Trying to edit the left side of a git diff file comparison

If you clicked on the source control icon in the Activity bar on the left, you most likely opened a git diff split screen.

The left side of the screen is the previous version of the file, so you aren't able to edit it.

Lỗi cannot edit in read only editor vscode

To resolve the issue, click on the explorer icon at the top of the Activity bar and open the file in editable mode.

Lỗi cannot edit in read only editor vscode

You shouldn't see two versions of the file in a split screen once you open it in editable mode.

Try to disable your extensions

If the error persists, try to disable your extensions.

  1. Press:
  2. Ctrl + Shift + P on Windows and Linux
  3. Command + Shift + P on macOS

Note: you can also press

Copied!

# Windows taskkill /F /IM code.exe

2 to open the Command Palette.

  1. Type disable extensions and select Extensions: Disable all installed extensions.
  2. Restart VS Code.
  3. Check if you can edit the file.

If you can edit the file after disabling all installed extensions, try to enable them one by one to see which extension caused the issue.

I've also written an error on how to solve the issue where the Live Server extension doesn't work in VS Code.