在 VScode 中,有没有一种方法可以使用快捷方式每两行或三行转到下一行?

In VScode, is there a way to go next line per two or three with shortcut?

我通常使用 ctrl + n/p 转到 VSCode 中的 next/previous 行。但是有时让我觉得很无聊,因为当我想浏览文件时,光标只走一行casually.Then,有没有办法让光标走几行或其他更快速的浏览文件的方法(比如转到下一个 class 或方法定义)?

据我所知,目前没有捷径可以跳过没有扩展名的多行。但是,ctrl + shift + o(默认情况下)或在您的搜索查询前加上@(默认情况下ctrl + p)可用于浏览文件中的符号,这可能正是您要查找的内容。

来自分机 Select By 你可以使用 moveby.calculation 命令。

keybindings.json

{
    "key": "ctrl+i ctrl+5",  // or any other key binding
    "when": "editorTextFocus",
    "command": "moveby.calculation",
    "args": {
      "lineNrEx": "selection.start.line + 5",
      "charNrEx": "selection.start.character"
    }
  }


V.S 中的跳线。代码




V.S。代码键盘快捷键


        V.S. Code offers its users the ability to customize Keyboard Shortcuts using navigational type commands that move the cursor, via the "keybindings.json" configuration file. When the "keybindings.json" file is configured properly you are able to use Keyboard Shortcuts to jump up n-lines, jump down n-lines, jump left n-chars, or to jump right n-chars.

  • NOTE: "n can equal any number".


入门


        To navigate the cursor in the fashoin that this topic covers, you will need to configure a few customized V.S. Code Keybindings (aka Keyboard Shortcuts). If this is not somthing that you have done before you don't need to worry. Binding a shortcut to a unique combonation of keys is actually quite simple, and it can be whimsical as well. It certainly will improve your V.S. Code experiance.

To get started creating your "line-jumping" Keyboard Shortcuts follow the instructions below. If you need any extra help during the keybinding creation process you can use the official V.S. Code, community maintained, documentation as a guide. I have posted the link below:

V.S. Code: Keyboard Shortcuts



  1. – 使用F1键打开您的“快速输入下拉菜单”

  2. – 在“快速输入菜单”中键入“键盘快捷键”

  3. – Select "打开键盘快捷键(JSON)"

注意:将有两个 “键盘快捷键” 选项供您选择。其中一个选项将读取默认值,而一个 WILL NOT 将读取默认值。确保 select 不会 读取默认值。如果您不熟悉快捷键,并且之前从未创建过快捷键,那么该文件应该是空的。


进入 keybindings.json 文件后,将以下“JSON”块添加到文件中

// "keybindings.json"

{
  {
    "key": "ctrl+1",
    "when": "editorTextFocus",
    "command": "cursorMove",
    "args": {
      "by": "line",
      "to": "down",
      "value": 1
    }
  },

  {
    "key": "ctrl+2",
    "when": "editorTextFocus",
    "command": "cursorMove",
    "args": {
      "by": "line",
      "to": "down",
      "value": 5
    }
  },

  {
    "key": "ctrl+3",
    "when": "editorTextFocus",
    "command": "cursorMove",
    "args": {
      "by": "line",
      "to": "down",
      "value": 10
    }
  },

  {
    "key": "ctrl+shift+1",
    "when": "editorTextFocus",
    "command": "cursorMove",
    "args": {
      "by": "line",
      "to": "up",
      "value": 1
    }
  },

  {
    "key": "ctrl+shift+2",
    "when": "editorTextFocus",
    "command": "cursorMove",
    "args": {
      "by": "line",
      "to": "up",
      "value": 5
    }
  },

  {
    "key": "ctrl+shift+3",
    "when": "editorTextFocus",
    "command": "cursorMove",
    "args": {
      "by": "line",
      "to": "up",
      "value": 10
    }
  },
}

"The above is only for testing purposes, as the keybindings are simple, and override default VSCode keybindings. You will have to decide which keybindings work best for you, however; if you add the above to your "keybindings.json" file you will get the following Keyboard Shortcuts"

  1. 跳下一行 CTRL+1

  2. 向下跳转 5 行 CTRL+2

  3. 向下跳转 10 行 CTRL+3

  4. 向上跳一行 CTRL+SHIFT+1

  5. 向上跳转 5 行 CTRL+SHIFT+2

  6. 向上跳转 10 行 CTRL+SHIFT+3



更多帮助:


如需进一步帮助,请访问 VSCode 命令页面以获取所有命令的列表,或专门阅读有关 cursorMove 命令的内容 @:
...或阅读有关键绑定的信息,请访问开源社区维护的 VSCode 文档集合中包含的键绑定页面 @: