在 VScode 中,有没有办法通过快捷方式每两个或三个下一行? [英] In VScode, is there a way to go next line per two or three with shortcut?

查看:35
本文介绍了在 VScode 中,有没有办法通过快捷方式每两个或三个下一行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我通常使用 ctrl + n/p 转到 VSCode 中的下一行/上一行.但是有时候让我觉得很无聊,因为当我想随便浏览文件时,它的光标只走了一行. 那么,有没有办法让光标 走几行或其他更快捷的方式来浏览文件(如 go到下一个类或方法定义)?

解决方案



V.S. 中的跳线代码




V.S.代码键盘快捷键


<块引用>

V.S.代码为用户提供了使用移动光标的导航类型命令自定义键盘快捷键的能力,通过keybindings.json"配置文件.当"keybindings.json"文件配置正确后,您就可以使用键盘快捷键来跳n-lines,向下跳n-lines,向左跳n-chars,或向右跳>n-chars.

  • 注意:n 可以等于任何数字".



入门


<块引用>

要在本主题涵盖的字体中导航光标,您需要配置一些自定义的 V.S.代码键绑定(又名键盘快捷键).如果这不是您之前做过的事情,则无需担心.将快捷键绑定到一个独特的键组合实际上非常简单,而且也可以是异想天开的.它肯定会改善您的 V.S.代码体验.

要开始创建您的跳线" 键盘快捷键,请按照以下说明进行操作.如果您在键绑定创建过程期间需要任何额外帮助,您可以使用官方 V.S.代码,社区维护,文档作为指南.我已经发布了以下链接:

V.S.代码:键盘快捷键



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

  2. – 输入键盘快捷键";进入快速输入菜单".

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

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


进入 keybindings.json 文件后,添加以下JSON":阻塞到文件

//"keybindings.json";{{键":ctrl+1",当":editorTextFocus",命令":光标移动",参数":{by":线",到":向下",值":1}},{键":ctrl+2",当":editorTextFocus",命令":光标移动",参数":{by":线",到":向下",值":5}},{键":ctrl+3",当":editorTextFocus",命令":光标移动",参数":{by":线",到":向下",值":10}},{键":ctrl+shift+1",当":editorTextFocus",命令":光标移动",参数":{by":线",到":向上",值":1}},{键":ctrl+shift+2",当":editorTextFocus",命令":光标移动",参数":{by":线",到":向上",值":5}},{键":ctrl+shift+3",当":editorTextFocus",命令":光标移动",参数":{by":线",到":向上",值":10}},}

<块引用>

"以上仅用于测试目的,因为键绑定很简单,并且会覆盖默认的 VSCode 键绑定.但是,您必须决定哪种键绑定最适合您;如果您将上述内容添加到您的keybindings.json"中;您将获得以下文件 键盘快捷键"


  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 文档集 @:
的键绑定页面

I usually use ctrl + n/p to go to next/previous line in VSCode. But it sometimes makes me feel dull because it has the cursor go just one line when I want to browse the file casually.Then, is there way to have the cursor go per a few lines or other more quick way to browse file(like go to next class or method definition)?

解决方案



Jumping Lines in V.S. Code




V.S. Code Keyboard Shortcuts


        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".



Getting Started


        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. – Use the F1 Key to open your "Quick Input Drop-Down Menu"

  2. – Type "Keyboard Shortcut" into the "Quick Input Menu".

  3. – Select "Open Keyboard Shortcuts (JSON)"

Note: There will be two "Keyboard Shortcut" options that you will be able to choose from. One of the options will read default, and one WILL NOT read default. Make sure to select the one that DOES NOT read default. If you are unfamiliar with keybindings, and have never created one before then the file should be totally empty.


Once inside of the keybindings.json file, add the following "JSON" block to the file

// "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. Jump Down a Line      CTRL+1

  2. Jump Down 5 Lines    CTRL+2

  3. Jump Down 10 Lines  CTRL+3

  4. Jump Up a Line      CTRL+SHIFT+1

  5. Jump Up 5 Lines    CTRL+SHIFT+2

  6. Jump Up 10 Lines  CTRL+SHIFT+3



For More Help:


For further assistance Visit the VSCode Commands Page to a list of all commands, or to read specifically about the cursorMove command @:
...or to read about keybindings visit keybindings page that is included the opensource community maintained VSCode documentation collection @:


这篇关于在 VScode 中,有没有办法通过快捷方式每两个或三个下一行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆