如何防止在使用CTRL +左/右箭头时,Visual Studio Code光标跳过符号?

huangapple go评论62阅读模式
英文:

How can I prevent Visual Studio Code cursor skipping symbols when using CTRL + Left/Right Arrow?

问题

从我的屏幕截图位置开始,如果我按<kbd>ctrl</kbd>+<kbd>left</kbd>,光标会跳过.符号。对于={也是一样,会跳过=符号。如何在VS Code中防止这种行为,不跳过它们?在JetBrains产品中,它的工作方式是这样的,而在VS Code中这确实让我困扰。

如何防止在使用CTRL +左/右箭头时,Visual Studio Code光标跳过符号?

英文:

From the position in my screenshot, if I do <kbd>ctrl</kbd>+<kbd>left</kbd>, the cursor will skip the . symbol. Same for ={, it will skip = symbol. How can I prevent this behavior in VS Code, and not skip that? In JetBrains products, it works like that, and it's really bothers me in VS Code.

如何防止在使用CTRL +左/右箭头时,Visual Studio Code光标跳过符号?

答案1

得分: 0

我相信您希望将 cursorWordStartLeftcursorWordStartRight 绑定在一起。您可以将它们设置为您想要的任何值,但您可能希望它们与 cursorWordLeftcursorWordRight 相同。当然,您可能还希望解除绑定其他控件。在条件相同的情况下,您可能还希望设置为 textInputFocus && !accessibilityModeEnabled

如何防止在使用CTRL +左/右箭头时,Visual Studio Code光标跳过符号?

在设置了这些绑定之后,光标的行为会更符合您的期望:

如何防止在使用CTRL +左/右箭头时,Visual Studio Code光标跳过符号?

英文:

I believe you want the cursorWordStartLeft and cursorWordStartRight bindings to be bound. You can set them to whatever you want, but you probably want them to be the same as the cursorWordLeft and cursorWordRight. Of course you also probably want to unbind the other controls too. You also probably want the same when condition which is textInputFocus &amp;&amp; !accessibilityModeEnabled:

如何防止在使用CTRL +左/右箭头时,Visual Studio Code光标跳过符号?

After setting this bindings, the cursor behaves more like how you want:

如何防止在使用CTRL +左/右箭头时,Visual Studio Code光标跳过符号?

答案2

得分: 0

以下是已翻译好的部分:

有以下关键绑定命令,您可以进行实验并根据自己的喜好进行调整:cursorWordStartLeft(光标移到左边的单词开头)、cursorWordStartRight(光标移到右边的单词开头)、cursorWordEndLeft(光标移到左边的单词末尾)和 cursorWordEndRight(光标移到右边的单词末尾)。

还有一些类似 cursorWordAccessibilityLeft(似乎跳过更多内容)、cursorWordPartLeft(例如,在驼峰式单词中停在大写字母处)以及 cursorWordPartStartLeft(光标移到左边的单词部分开头)等命令,您可以进行实验。

例如,以下是如何取消默认绑定的 cursorWordLeftcursorWordRight,并改为将它们绑定到 ctrl+leftctrl+right 的示例:

// 解绑默认命令:
{
    "key": "ctrl+left",
    "command": "-cursorWordLeft",
    "when": "textInputFocus"
},
{
    "key": "ctrl+right",
    "command": "-cursorWordRight",
    "when": "textInputFocus"
},
// 绑定自定义命令:
{
    "key": "ctrl+left",
    "command": "cursorWordStartLeft",
    "when": "textInputFocus"
},
{
    "key": "ctrl+right",
    "command": "cursorWordEndRight",
    "when": "textInputFocus"
},
英文:

There are the following keybinding commands that you can experiment with using, and tuning to your taste: cursorWordStartLeft, cursorWordStartRight, cursorWordEndLeft, and cursorWordEndRight.

There are also things like cursorWordAccessibilityLeft (seems to skip more), cursorWordPartLeft (Ex. stops at things like capitals in camel-case words), and cursorWordPartStartLeft that you can experiment with.

For example here's how you can unbind the default cursorWordLeft and cursorWordRight from <kbd>ctrl</kbd>+<kbd>left</kbd> and <kbd>ctrl</kbd>+<kbd>right</kbd>, and instead bind them to cursorWordStartLeft and cursorWordEndRight:

// unbind defaults:
{
    &quot;key&quot;: &quot;ctrl+left&quot;,
    &quot;command&quot;: &quot;-cursorWordLeft&quot;,
    &quot;when&quot;: &quot;textInputFocus&quot;
},
{
    &quot;key&quot;: &quot;ctrl+right&quot;,
    &quot;command&quot;: &quot;-cursorWordRight&quot;,
    &quot;when&quot;: &quot;textInputFocus&quot;
},
// bind customizations:
{
    &quot;key&quot;: &quot;ctrl+left&quot;,
    &quot;command&quot;: &quot;cursorWordStartLeft&quot;,
    &quot;when&quot;: &quot;textInputFocus&quot;
},
{
    &quot;key&quot;: &quot;ctrl+right&quot;,
    &quot;command&quot;: &quot;cursorWordEndRight&quot;,
    &quot;when&quot;: &quot;textInputFocus&quot;
},

huangapple
  • 本文由 发表于 2023年5月21日 05:46:11
  • 转载请务必保留本文链接:https://go.coder-hub.com/76297472.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定