0

I'm really liking VS Code, but I've looked everywhere and I can't seem to change one very annoying feature: pressing return on an empty indented line carries over the current indentation, but removes all indentation on the original line. It seems impossible to have two consecutive tab-indented lines in the editor.

Is there a setting I'm missing or some other way to preserve the tab-indentation across lines? Thanks.

2 Answers2

1

We can setup user settings for this, Go to File > Preferences > User Settings:

You can customize this easily via these 3 settings in / The number of spaces a tab is equal to. This setting is overriden // based on the file contents when editor.detectIndentation is true. "editor.tabSize": 4,

// Insert spaces when pressing Tab. This setting is overriden // based on the file contents when editor.detectIndentation is true. "editor.insertSpaces": true,

// When opening a file, editor.tabSize and editor.insertSpaces // will be detected based on the file contents. "editor.detectIndentation": true

For more information - We can setup user settings for this, Go to File > Preferences > User Settings:

You can customize this easily via these 3 settings in / The number of spaces a tab is equal to. This setting is overriden // based on the file contents when editor.detectIndentation is true. "editor.tabSize": 4,

// Insert spaces when pressing Tab. This setting is overriden // based on the file contents when editor.detectIndentation is true. "editor.insertSpaces": true,

// When opening a file, editor.tabSize and editor.insertSpaces // will be detected based on the file contents. "editor.detectIndentation": true

For more info you can check here - How to set tab-space style?

0

I have figured out my problem:

In Settings, "editor.trimAutoWhitespace" is true by default, meaning any trailing tabs left on a line are automatically deleted, even if they are just holding the regular indentation level. I have fixed my problem by setting this option to false in my User Settings (File / Preferences / Settings).

I am surprised that I can't find any record of anyone else having found this behavior unusual.