'Block must not be padded by blank lines. (padded-blocks)

Is there a way to configure VS Code in order to avoid padding, via format line (Shift + Alt + F)?

For instance the first line after the if statement is empty (padded):

if (a) {

    b()
}

The empty line after the if statement should be removed as following:

if (a) {
    b()
}

This should be done automatic by pressing Shift + Alt + F. Can the settings be configured accordingly in VS Code?

Thanks!



Solution 1:[1]

Vscode itself does not provide that settings. You could use the the Beautify extension with its preserve_newlines and max_preserve_newlines settings to achieve this behavior. An overview of all possible settings can be found here.
After you configured your settings you can create a custom shortcut in the keybindings.json to overwrite the default Shift + Alt + F

{
    "key": "shift+alt+f",
    "command": "HookyQR.beautify",
    "when": "editorFocus"
}

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1