Language extensions can provide rules for increasing/decreasing indentation when writing new lines and copy-pasting code. The VS Code documentation for this feature is here https://code.visualstudio.com/updates/v1_14#_auto-indent-on-type-move-lines-and-paste
Some scenarios where the current indentation behavior can be improved, the | marker is the position of the cursor
-- obtained
++ expected
val x =
- |
+ |
val x = (n: Int) =>
- |
+ |
1 match {
case 1 =>
- |
+ |
To play around with this feature, the language-configuration.json file needs to be updated with regex rules like this:
{
"indentationRules": {
"increaseIndentPattern": "^\\s*((begin|class|def|else|elsif|ensure|for|if|module|rescue|unless|until|when|while)|(.*\\sdo\\b))\\b[^\\{;]*$",
"decreaseIndentPattern": "^\\s*([}\\]]([,)]?\\s*(#_|$)|\\.[a-zA-Z_]\\w*\\b)|(end|rescue|ensure|else|elsif|when)\\b)"
}
}
https://github.com/scala/vscode-scala-syntax/blob/5211d13c231498d0ca4480a81e1e9cfa4741875b/language-configuration.json
Language extensions can provide rules for increasing/decreasing indentation when writing new lines and copy-pasting code. The VS Code documentation for this feature is here https://code.visualstudio.com/updates/v1_14#_auto-indent-on-type-move-lines-and-paste
Some scenarios where the current indentation behavior can be improved, the
|marker is the position of the cursorTo play around with this feature, the
language-configuration.jsonfile needs to be updated with regex rules like this:{ "indentationRules": { "increaseIndentPattern": "^\\s*((begin|class|def|else|elsif|ensure|for|if|module|rescue|unless|until|when|while)|(.*\\sdo\\b))\\b[^\\{;]*$", "decreaseIndentPattern": "^\\s*([}\\]]([,)]?\\s*(#_|$)|\\.[a-zA-Z_]\\w*\\b)|(end|rescue|ensure|else|elsif|when)\\b)" } }https://github.com/scala/vscode-scala-syntax/blob/5211d13c231498d0ca4480a81e1e9cfa4741875b/language-configuration.json