VSCode 跳转到当前行的中间

VSCode jump to the middle of current line

Visual Studio代码中有很多键盘shortcuts and edit选项,我可以移动光标:按字符,按单词,到beginning/end行。但是,如果我正在编辑一长行文本,如何更快地跳转到这一行的中间?

在这里发现了类似的问题,但对于 vim 用户 - 视觉上 select 到行的中间

可能可以使用 Vim 扩展来实现此选项(跳转到中间)。如果可以,那该怎么做?

有没有办法在没有任何扩展的情况下在本机实现这种行为?

您可以使用扩展 Select By v1.0.0.

您可以创建一个键绑定来计算新的光标位置

  {
    "key": "ctrl+i ctrl+m",  // or any other key binding
    "when": "editorTextFocus",
    "command": "moveby.calculation",
    "args": {
      "charNrEx": "currentLine.length / 2"
    }
  }

实际上,这是 vscode 的内置功能,使用 cursorMove 命令。在 keybindings.json:

中设置此键绑定
{
  "key": "alt+c",
  "command": "cursorMove",
  "args": {
    "to": "wrappedLineColumnCenter",
    "select": true  // default is false
  }
}