6

我想知道是否可以在不删除标记文本的情况下使用制表键缩进一行。

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

第一个:VS Code,第二个:ATOM-Editor

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

VS Code 缩进多行

这是错误还是正常行为?

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

4

3 回答 3

2
You could use this default keybinding:

{
  "key": "ctrl+]",
  "command": "editor.action.indentLines",
  "when": "editorTextFocus && !editorReadonly"
}

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

{
  "key": "tab",
  "command": "editor.action.indentLines",
  "when": "editorHasSelection && editorTextFocus && !editorReadonly"
}

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

于 2018-07-19T14:02:32.997 回答
1

据我了解,这是预期的行为。要缩进一行,您需要:

  • 将光标放在行首,然后制表符
  • 选择整行 (Mac: Command+i, Windows/Linux: Ctrl+i) 然后 tab
  • 使用 indent line 命令,可以使用 GIF 中显示的单词来完成(Mac: Command+], Windows/Linux: Ctrl+]

不过,可能有一个可用的扩展程序可以为您提供所需的行为。

于 2018-07-19T13:56:31.993 回答
0

在这里添加另一种风味:

如果您希望 tab 像 shift-tab 一样工作(您不必突出显示任何内容),并且如果您使用 tab 作为接受自动完成建议的键,请使用以下设置:

{
  "key": "tab",
  "command": "editor.action.indentLines",
  "when": "!suggestWidgetVisible && editorTextFocus && !editorReadonly"
}
于 2021-09-20T17:26:32.517 回答