VSCode: keeping indents on empty lines

后端 未结 5 1405
日久生厌
日久生厌 2020-12-29 20:41

Is it possible to make VSCode keep indents on empty lines?

Could not find such a setting neither natively nor in \"Beautify\" extension.

Example of desired b

相关标签:
5条回答
  • 2020-12-29 21:02

    Go to File > Preferences > Settings. On the right side, add the line:

    ,"editor.trimAutoWhitespace": false
    

    It worked for me perfectly.

    0 讨论(0)
  • 2020-12-29 21:03

    The command editor.action.insertLineAfter makes a new line and moves the cursor there preserving the indentation. To bind that command to Enter key, go to your keyboard shortcuts (press ctrl + k ctrl + s) then press the two curly braces button on the far right top.

    add the following command

        {
        "key": "enter",
        "command": "editor.action.insertLineAfter",
        "when": "editorTextFocus && !editorReadonly"
    },
    

    Make sure it's before the end of the Json list.

    0 讨论(0)
  • 2020-12-29 21:04

    Bit of an old question, but I found that a combination of the settings:

    "editor.trimAutoWhitespace": false,
    "editor.renderWhitespace": "all"
    

    ...worked for me.

    0 讨论(0)
  • 2020-12-29 21:05

    That is probably eslint (and/or beautify) doing that. Look at

    "no-trailing-spaces": ["error", { "skipBlankLines": false }],
    

    I have that in my eslintrc.json file and so I get errors on blank lines with spaces or tabs on them. Setting "skipBlankLines" to true might work for you.

    0 讨论(0)
  • 2020-12-29 21:10

    I had the same issue but after removing :

    "editor.autoIndent": "none"
    

    I was good to go.

    0 讨论(0)
提交回复
热议问题