英文:
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中这确实让我困扰。
英文:
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.
答案1
得分: 0
我相信您希望将 cursorWordStartLeft
和 cursorWordStartRight
绑定在一起。您可以将它们设置为您想要的任何值,但您可能希望它们与 cursorWordLeft
和 cursorWordRight
相同。当然,您可能还希望解除绑定其他控件。在条件相同的情况下,您可能还希望设置为 textInputFocus && !accessibilityModeEnabled
:
在设置了这些绑定之后,光标的行为会更符合您的期望:
英文:
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 && !accessibilityModeEnabled
:
After setting this bindings, the cursor behaves more like how you want:
答案2
得分: 0
以下是已翻译好的部分:
有以下关键绑定命令,您可以进行实验并根据自己的喜好进行调整:cursorWordStartLeft
(光标移到左边的单词开头)、cursorWordStartRight
(光标移到右边的单词开头)、cursorWordEndLeft
(光标移到左边的单词末尾)和 cursorWordEndRight
(光标移到右边的单词末尾)。
还有一些类似 cursorWordAccessibilityLeft
(似乎跳过更多内容)、cursorWordPartLeft
(例如,在驼峰式单词中停在大写字母处)以及 cursorWordPartStartLeft
(光标移到左边的单词部分开头)等命令,您可以进行实验。
例如,以下是如何取消默认绑定的 cursorWordLeft
和 cursorWordRight
,并改为将它们绑定到 ctrl+left
和 ctrl+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:
{
"key": "ctrl+left",
"command": "-cursorWordLeft",
"when": "textInputFocus"
},
{
"key": "ctrl+right",
"command": "-cursorWordRight",
"when": "textInputFocus"
},
// bind customizations:
{
"key": "ctrl+left",
"command": "cursorWordStartLeft",
"when": "textInputFocus"
},
{
"key": "ctrl+right",
"command": "cursorWordEndRight",
"when": "textInputFocus"
},
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论