Visual studio code 在清除缩进的同时插入上面的行

Visual studio code 在清除缩进的同时插入上面的行,visual-studio-code,Visual Studio Code,在使用VS代码时,我经常希望在当前位置的上方添加两行。理想情况下,我希望使用⇧⌘输入两次,但当我这样做时,会得到一个带有缩进的空行: ····*cursor is now here* ····*blank line with indentation* ····some code *cursor was here* some code 我想要与下面的插入行命令相同的行为⌘输入has,将自动删除空行的缩进: ····some code *cursor was here* some code *bl

在使用VS代码时,我经常希望在当前位置的上方添加两行。理想情况下,我希望使用
⇧⌘输入两次
,但当我这样做时,会得到一个带有缩进的空行:

····*cursor is now here*
····*blank line with indentation*
····some code *cursor was here* some code
我想要与下面的插入行命令相同的行为
⌘输入
has,将自动删除空行的缩进:

····some code *cursor was here* some code
*blank line without indentation*
····*cursor is now here*

您可以创建一个新命令来替换密钥绑定并获得请求的结果

使用扩展并将其添加到
设置.json

  "multiCommand.commands": [
    {
      "command": "multiCommand.lineAbove",
      "sequence": [
        "cursorHome",
        "cursorHome",
        "cursorUp",
        "cursorEnd",
        "cursorEnd",
        { "command": "type", "args": { "text": "\n" }}
      ]
    }
  ]
  {
    "key": "ctrl+shift+enter",
    "command": "-editor.action.insertLineBefore"
  },
  {
    "key": "ctrl+shift+enter",
    "command": "multiCommand.lineAbove"
  }
命令重复用于处理长行和换行

将以下内容添加到您的
keybindings.json

  "multiCommand.commands": [
    {
      "command": "multiCommand.lineAbove",
      "sequence": [
        "cursorHome",
        "cursorHome",
        "cursorUp",
        "cursorEnd",
        "cursorEnd",
        { "command": "type", "args": { "text": "\n" }}
      ]
    }
  ]
  {
    "key": "ctrl+shift+enter",
    "command": "-editor.action.insertLineBefore"
  },
  {
    "key": "ctrl+shift+enter",
    "command": "multiCommand.lineAbove"
  }
您必须更改Mac OS的按键组合