英文:
How to prevent VS Code from deleting the next word characters on IntelliSense auto-completion?
问题
这个问题类似于 https://stackoverflow.com/q/22075360/1027706,但针对的是 Visual Studio Code 而不是 Visual Studio。
当从列表中选择一个完成建议时,它会被插入,但光标后的单词中的所有字符都被删除。(因此,如果光标后有空格,什么都不会发生。但如果在单词开头放置光标时触发自动完成,该单词将被删除)。
是否有一种方法可以禁用这种删除行为,并让它在不删除光标右侧文本的情况下添加所选建议?
英文:
This question is analogous to https://stackoverflow.com/q/22075360/1027706,
but targeted at Visual Studio Code instead of Visual Studio.
When a completion suggestion is selected from the list, it is inserted, but all characters from the word after the cursor are deleted. (So, nothing happens if there is a whitespace after the cursor. But if autocompletion is triggered while the cursor is placed at the beginning of a word, said word will be deleted).
Is there a way to disable this deletion behavior and get it to add the selected suggestion without deleting text to the right of the caret?
答案1
得分: 11
检查你的 settings.json
文件(你的用户 settings.json
和工作区 .vscode/settings.json
)。
你可能会有这样一行设置:
"editor.suggest.insertMode": "replace"
你可以删除它以恢复默认行为,即使用 insert
而不是 replace
,或者只需将其更改为 insert
。
该设置的描述如下:
控制在接受建议时是否覆盖单词。请注意,这取决于扩展是否选择此功能。
insert
值的描述如下:
在光标右侧插入建议,而不覆盖文本。
replace
值的描述如下:
插入建议并覆盖光标右侧的文本。
对于某些语言,默认设置可能会更改。您可以通过使用 Preferences: Open Default Settings (JSON)
命令查看 defaultSettings.json
文件来查看所有默认设置。
要按语言设置设置,请将它们封装在类似于以下示例的块中(C++ 的示例):
"[cpp]": {
"editor.suggest.insertMode": "insert"
}
英文:
Check your settings.json files (your user settings.json
and your workspace .vscode/settings.json
).
You probably have a line that says:
"editor.suggest.insertMode": "replace"
You can either delete it to get the default behaviour, which is "insert"
instead of "replace"
, or just change it to "insert"
.
The setting's description says:
> Controls whether words are overwritten when accepting completions. Note that this depends on extensions opting into this feature.
The "insert"
value's description says:
> Insert suggestion without overwriting text right of the cursor.
The "replace"
value's description says:
> Insert suggestion and overwrite text right of the cursor.
For some languages, the default might be changed. You can check all default settings by viewing the defaultSettings.json file using the Preferences: Open Default Settings (JSON)
command.
To set settings per-language, enclose them in blocks like this (example for C++):
"[cpp]": {
"editor.suggest.insertMode": "insert"
}
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论