Search code examples
visual-studio-codesassindentation

How to stop VSCode indenting when pushing existing code to a new line?


enter image description here

I have some code written, every time I press Enter to push it lower, it keeps indenting it. Is there a way to stop this behavior?


Solution

  • The indent is caused by the onEnterRules of the full/advanced setting of the Editor: Auto Indent preference:

    settings screenshot

    To avoid the problem, you could change the setting to keep or none, but be aware it changes your preference globally (for any file type where indenting would apply).

    It looks like there might be a way to configure the onEnterRules per language, but I'm not entirely sure how to do that yet. Editing the language specific setting in JSON with the following config did not work for me:

    {
      "[scss]": {
        "editor.autoIndent": "keep"
      }
    }