使用不同的分离器以两种方式在单词之间导航

发布于 2025-02-08 20:58:04 字数 532 浏览 2 评论 0原文

感谢 Visual Studio code> Visual Studio Code- customizing Word Syparators 分离器。 因此,现在每当我按 ctrl +左箭头时,VS代码都会识别该单词在下划线后立即开始。 但是,有时我想在变量/函数/班级名称的最初开始,并使用下划线作为隔板,我必须按 ctrl +左箭头几次到达那里。 是否有任何方法可以得到以下行为:

  • ctrl +左箭头它将下划线视为分隔符
  • ctrl ++ alt alt alt +左箭头它不认为下划线为分离器

Thanks to Visual Studio Code—Customizing word separators I was able to set underscore as separator.
So now whenever I press Ctrl+Left Arrow, VS code recognizes that the word starts right after the underscore.
However sometimes I want go at the very beginning of the variable/function/class name and, using underscore as separator, I have to press
Ctrl+Left Arrow several times to get there.
Is there any way to get a behavior like:

  • Ctrl+Left Arrow it considers underscore as separator
  • Ctrl+Alt+Left Arrow it doesn't consider underscore as separator

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

土豪我们做朋友吧 2025-02-15 20:58:04

您可以很容易地使用宏扩展“ nofollow noreferrer”> multi-command 。在keybindings.json中制作此键键,

{
  "key": "ctrl+alt+left",
  "command": "extension.multiCommand.execute",
  "args": {
    "sequence": [
      "editor.action.smartSelect.grow",
      "editor.action.smartSelect.grow",
      "cursorLeft"    // just gets rid of the selection
    ]
  },
}

”移动while

You can do this quite easily with the macro extension multi-command. Make this keybinding in your keybindings.json:

{
  "key": "ctrl+alt+left",
  "command": "extension.multiCommand.execute",
  "args": {
    "sequence": [
      "editor.action.smartSelect.grow",
      "editor.action.smartSelect.grow",
      "cursorLeft"    // just gets rid of the selection
    ]
  },
}

move to start of while word

瑕疵 2025-02-15 20:58:04

正如RIOV8所说,您可以使用 by plugin。

请按照以下步骤操作以获取您想要的内容:

  1. 从您的Visual Studio代码扩展选项卡(Ctrl+Shift+X)中安装插件,然后
  2. 单击左下方齿轮,然后单击此图片
  3. 在“键盘快捷键”选项卡的右上角,您会找到三个图标,单击一个图标左,如此图片(或
  4. JSON文件中的 ctrl+k ctrl+s)它已经出现在您的屏幕上,粘贴以下内容:
  {
    "key": "ctrl+alt+right",  // or any other key combo
    "when": "editorTextFocus",
    "command": "moveby.regex",
    "args": [
      "moveAvoidUnderscore",
      "moveby",
      "next",
      "end"
    ]
  }

或至少在文件末尾插入此快捷方式,之后是','。
您应该拥有类似的东西

  1. 文件>偏好>设置(Ctrl+,),搜索selectby

  2. 单击在settings.json

    中编辑

  3. 替换您拥有的任何内容:

{
    "selectby.regexes": {
        "moveAvoidUnderscore": {
            "moveby": " "
        }
    }
}
  1. 向左设置:替换“键”:“ Ctrl+Alt+左”“ args”:[...,“ prev”,“ start”,“ start” ]

如果我什么都没错过,那么你应该很好:)

As rioV8 said, you can use the Select By plugin.

Follow these steps to get pretty much what you want:

  1. Install the plugin from your Visual Studio Code Extensions tab (Ctrl+Shift+X)
  2. Click on the bottom left gear and click on "Keyboard Shortcuts" as in this picture
  3. At the top right corner of the "Keyboard Shortcuts" tab, you'll find three icons, click on the one at the left, as in this picture (or Ctrl+k Ctrl+s)
  4. In the json file that has appeared on your screen, paste this:
  {
    "key": "ctrl+alt+right",  // or any other key combo
    "when": "editorTextFocus",
    "command": "moveby.regex",
    "args": [
      "moveAvoidUnderscore",
      "moveby",
      "next",
      "end"
    ]
  }

Or at least insert this shortcut at the end of the file, following a ','.
You should have something like this.

  1. In File > Preferences > Settings (Ctrl+,), search for selectby

  2. Click Edit in settings.json

  3. Replace anything you have with that:

{
    "selectby.regexes": {
        "moveAvoidUnderscore": {
            "moveby": " "
        }
    }
}
  1. To setup left: replace "key": "ctrl+alt+left" and "args": [ ..., "prev", "start" ]

If I didn't miss anything, you should be good to go :)

柠檬色的秋千 2025-02-15 20:58:04

实现所需行为的另一种可能方法是通过以下步骤:

  1. _排除在单词分离器中,以防万一您仍然包括在内。

  2. 将以下两个键键添加到keybindings.json

      {      
        “键”:“ Ctrl+Shift+左”,    
         “命令”:“ cursorwordleft”,
         “当”:“ textInputfocus”
     },,
    
     {
         “键”:“ ctrl+左”,
         “命令”:“ cursorwordpartleft”,
         “当”:“ textInputfocus”
     }
     

第一个键键键允许您通过按下 ctrl + << ctrl kbd> shift + 左箭头

第二个键界允许您通过按 ctrl + 左箭头来移动单词的左侧,但考虑_这次。

Another possible way for achieving the desired behaviour is through the following steps:

  1. Exclude _ from the word separators in case you still have it included.

  2. Add the two following keybindings to your keybindings.json :

     {      
        "key": "ctrl+shift+left",    
         "command": "cursorWordLeft",
         "when": "textInputFocus"
     },
    
     {
         "key": "ctrl+left",
         "command": "cursorWordPartLeft",
         "when": "textInputFocus"
     }
    

The first keybinding allows you to move to the left of a word by pressing Ctrl + Shift + Left Arrow.

The second keybinding allows you to move to the left of a word by pressing Ctrl + Left Arrow but considering _ this time.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文