在 VS Code 中,有没有办法通过快捷方式每两行或三行转到下一行?

マスタ*_*ーダー 6 visual-studio-code

我通常使用Ctrl+ n/ Ctrl+p转到 VS Code 中的下一行/上一行。但有时它会让我感到沉闷,因为当我想随意浏览文件时,它的光标只走一行。

有没有办法让光标移动几行或其他更快速的方式来浏览文件(例如转到下一个类或方法定义)?

小智 8

免责声明:这并不完全是您想要的,但也许了解一下也会有用。

\n
\n

以下快捷键可用于在 VS Code 中插入新行(重复这些快捷键可根据需要插入任意多行):

\n

视窗/Linux

\n
    \n
  • CTRL+ Enter- 在下面插入行
  • \n
  • CTRL+ Shift+ Enter- 在上方插入行
  • \n
\n

苹果系统

\n
    \n
  • \xe2\x8c\x98 Enter- 在下面插入行
  • \n
  • \xe2\x87\xa7 \xe2\x8c\x98 Enter- 在上方插入行
  • \n
\n
\n

Visual Studio Code 的有用链接

\n\n


JΛY*_*ÐΞV 5


\n


\n

VS Code 中的跳行

\n
\n
\n
\n

VS Code 键盘快捷键

\n
\n
\n

\xc2\xa0 \xc2\xa0 \xc2\xa0 \xc2\xa0 VS Code使用户能够通过“keybindings.json”配置文件使用移动光标的导航类型命令来自定义键盘快捷键正确配置“keybindings.json”文件后,您可以使用键盘快捷键向上跳转-lines、向下跳转-lines、向左跳转-chars或向右跳转-charsnnnn

\n
    \n
  • 注意: n可以等于任何数字”。
  • \n
\n
\n
\n
\n

入门

\n
\n
\n

\xc2\xa0 \xc2\xa0 \xc2\xa0 \xc2\xa0 要在本主题涵盖的样式中导航光标,您将需要配置一些自定义的VS Code 按键绑定(也称为键盘快捷键)。如果这不是您之前做过的事情,则无需担心。将快捷方式绑定到独特的按键组合实际上非常简单,而且也可以是异想天开。它肯定会改善您的VS Code 体验

\n
要开始创建“跳线” 键盘快捷键,请按照以下说明操作。如果您在键绑定创建过程中需要任何额外帮助,您可以使用社区维护的官方VS Code文档作为指南。我已经发布了以下链接:
\n

VS Code:键盘快捷键

\n
\n
\n
\n
    \n
  1. \xe2\x80\x93 使用按键F1打开“快速输入下拉菜单”

    \n
  2. \n
  3. \xe2\x80\x93 在“快速输入菜单”中键入“键盘快捷键” 。

    \n
  4. \n
  5. \xe2\x80\x93 选择“打开键盘快捷键(JSON)”

    \n
  6. \n
\n
注意:您可以选择两个“键盘快捷键”选项。其中一个选项将读取默认值,而一个选项将不会读取默认值。确保选择读取默认值的一项。如果您不熟悉键绑定,并且以前从未创建过键绑定,那么该文件应该完全是空的。
\n
\n
\n

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

\n
// "keybindings.json"\n\n{\n  {\n    "key": "ctrl+1",\n    "when": "editorTextFocus",\n    "command": "cursorMove",\n    "args": {\n      "by": "line",\n      "to": "down",\n      "value": 1\n    }\n  },\n\n  {\n    "key": "ctrl+2",\n    "when": "editorTextFocus",\n    "command": "cursorMove",\n    "args": {\n      "by": "line",\n      "to": "down",\n      "value": 5\n    }\n  },\n\n  {\n    "key": "ctrl+3",\n    "when": "editorTextFocus",\n    "command": "cursorMove",\n    "args": {\n      "by": "line",\n      "to": "down",\n      "value": 10\n    }\n  },\n\n  {\n    "key": "ctrl+shift+1",\n    "when": "editorTextFocus",\n    "command": "cursorMove",\n    "args": {\n      "by": "line",\n      "to": "up",\n      "value": 1\n    }\n  },\n\n  {\n    "key": "ctrl+shift+2",\n    "when": "editorTextFocus",\n    "command": "cursorMove",\n    "args": {\n      "by": "line",\n      "to": "up",\n      "value": 5\n    }\n  },\n\n  {\n    "key": "ctrl+shift+3",\n    "when": "editorTextFocus",\n    "command": "cursorMove",\n    "args": {\n      "by": "line",\n      "to": "up",\n      "value": 10\n    }\n  },\n}\n\n
Run Code Online (Sandbox Code Playgroud)\n
\n
"以上仅用于测试目的,因为键绑定很简单,并且会覆盖默认的 VSCode 键绑定。但是,您必须决定哪种键绑定最适合您;如果将上述内容添加到您的“keybindings.json”文件中,您将获取以下 键盘快捷键
\n
\n
\n
    \n
  1. 下一行 \xc2\xa0 \xc2\xa0 \xc2\xa0 CTRL+1

    \n
  2. \n
  3. 向下跳 5 行 \xc2\xa0 \xc2\xa0 CTRL+2

    \n
  4. \n
  5. 向下跳转 10 行 \xc2\xa0 CTRL+3

    \n
  6. \n
  7. 跳行 \xc2\xa0 \xc2\xa0 \xc2\xa0 CTRL+ SHIFT+1

    \n
  8. \n
  9. 向上跳转 5 行 \xc2\xa0 \xc2\xa0 CTRL+ SHIFT+2

    \n
  10. \n
  11. 向上跳转 10 行 \xc2\xa0 CTRL+ SHIFT+3

    \n
  12. \n
\n
\n
\n

如需更多帮助:

\n
\n
如需进一步帮助,请访问 VSCode 命令页面以查看所有命令的列表,或具体阅读有关cursorMove命令 @ 的信息:
\n\n
...或者要阅读有关键绑定的信息,请访问键绑定页面,该页面包含开源社区维护的 VSCode 文档集合@:
\n\n
\n
\n