Search code examples
visual-studio-codeindentation

VSCode: Add newline between braces after pressing Enter


I want an indented newline after typing opening bracket and pressing Enter in VSCode.

Here's an example where | is the cursor:

Current behaviour-

function f() {
|}

Behaviour wanted-

function f() {
  |
}

The behaviour I want is the default one, but I don't know what happened and it doesn't work like that now. I couldn't find a solution to it, so I'm asking here. Thanks in advance


Solution

  • Finally, I found the issue. In settings.json somehow I had this included.

    "editor.language.brackets": [
        
    ]
    

    But by default it's not there, or rather this is the default setting:

    "editor.language.brackets": [
        ["[", "]"],
        ["(", ")"],
        ["{", "}"]
    ]
    

    TLDR: Just remove it.