VS code moves the cursor to start of next line when pressing enter key

Viewed 1471

Instead of respecting the current block's indentation level, the cursor moves to the start of the new line when pressing the enter key.

          {
             "name": "foo",
|
          }

The cursor should jump to the same level as the name key.

This happens even with the empty curly brackets.

          {|}

Hit enter

          {
|} 

There doesn't seem to be a setting that can be set so the cursor only jumps to the current indentation level.

3 Answers

For me, the default value of Editor:auto.indent was "full", but I still experienced the issue.
To fix, I needed to re-save Settings (after changing the option twice) to make it work in C#.

Option illustration in VS Code

I kind of fixed this issue by setting the Editor:auto.indent to "full".

This issue can also happen if you have "files.autoSave": "afterDelay". Saving the file moves your cursor at the beginning of the line, if line is empty.

Related