Visual Studio Code - 使用制表键缩进单行

mer*_*imo 6 indentation text-indent visual-studio-code

我想知道是否可以使用 tab 键缩进一行而不删除标记的文本。

在 GIF 的第一部分中,您可以看到 Visual Studio Code,在第二部分中可以看到 Atom。Atom 显示了所需的行为。

第一:VS Code,第二:ATOM 编辑器

到目前为止,可以在 VS Code 中以这种方式缩进多行,它也适用于后制表符,但不适用于制表符和单行。

VS Code 缩进多行

这是错误还是正常行为?

我的设置:
Visual Studio Code:版本 1.25.1 (MacOS 10.13.6 High Sierra)
Visual Studio Code:版本 1.25.1 (Ubuntu 18.04 LTS)

Mar*_*ark 2

You could use this default keybinding:

{
  "key": "ctrl+]",
  "command": "editor.action.indentLines",
  "when": "editorTextFocus && !editorReadonly"
}
Run Code Online (Sandbox Code Playgroud)

制表符单行或多行。如果您希望绑定到tab您可以将其修改为:

{
  "key": "tab",
  "command": "editor.action.indentLines",
  "when": "editorHasSelection && editorTextFocus && !editorReadonly"
}
Run Code Online (Sandbox Code Playgroud)

我添加了该 editorHasSelection子句,因此它在您的线路上选择了某些内容时才起作用,但是您将失去正常的简单tab行为(您不喜欢)。