可以将VS代码完成配置为接受关于标点符号的建议吗? [英] Can VS Code code completion be configured to accept a suggestion on punctuation?
问题描述
这个问题特别针对其他C#开发人员在VS Code中转向TypeScript。
This question is particularly pointed at other C# devs coming over to TypeScript in VS Code.
我爱上了VS C#中的代码完成。为了说明,说我正在尝试写:
I fell in love with the code completion in VS C#. To illustrate, say I'm trying to write:
console.log('hello')
使用C#,我会:
- 键入con
- 会出现一个建议列表,可能以console开头
- 因为突出显示它是我想要的,点击将写出鞋底。所以现在我有:
console。
- 输入l,log是第一个建议
- 输入(,现在我有:
console.log('')
- 光标现在位于' '
- 输入hello
- type "con"
- a list of suggestions would appear, probably starting with "console"
- since that's highlighted and it's what I want, hitting "." will write out "sole." so now I have:
console.
- type "l", "log" is the first suggestion
- type "(", now I have:
console.log('')
- cursor is now in the ''
- type "hello"
目前使用我的VS Code设置,同样的事情可以每次我想接受一个建议时,都可以通过JS / TS点击标签
来实现。但只是按下一个标点符号继续下去真是太好了,如果你原谅我关心它,有趣。我很想念它。我所知道的语言没有技术限制会禁止这种行为。
Currently with my VS Code setup, the same thing can be achieved in JS/TS hitting tab
each time I want to accept a suggestion. But just hitting the next punctuation to proceed was really nice and, if you forgive me for caring about it, "fun." I miss it. And there's no technical limitation of the languages that I know of that would prohibit this behavior.
任何人都知道是否有任何扩展或设置是否可以启用此功能?否则,此对话可能发生在哪里?
Anyone know if there's any extension or setting available to enable this? Or else, where else this conversation may be occurring ?
推荐答案
可以使用< a href =https://marketplace.visualstudio.com/items?itemName=geddski.macros#overview =nofollow noreferrer> macros extensi要执行此操作:
One can implement this oneself using the macros extension. To do this:
-
安装宏扩展
创建一个调用acceptSelectedSuggestion操作的宏,然后输入。
。这是我的Settings.json的样子:
Create a macro calling the acceptSelectedSuggestion action, then type .
. Here's what my Settings.json looked like:
{
"editor.wordWrap": "on",
"window.zoomLevel": 0,
"git.enableSmartCommit": true,
"macros": {
"accept.": [
"acceptSelectedSuggestion",
{"command": "type", "args": {"text": "."}}
],
"accept(": [
"acceptSelectedSuggestion",
{"command": "type", "args": {"text": "("}}
],
"accept=": [
"acceptSelectedSuggestion",
{"command": "type", "args": {"text": "="}}
]
}
}
将这些宏中的每一个添加到keybindings.json中的键绑定。我的其他键绑定看起来像:
Added each of these macros to a key binding in keybindings.json. My additional keybindings looked like:
{
"key": ".",
"command": "macros.accept.",
"when": "editorTextFocus && suggestWidgetVisible"
},
{
"key": "shift+9",
"command": "macros.accept(",
"when": "editorTextFocus && suggestWidgetVisible"
},
{
"key": "=",
"command": "macros.accept=",
"when": "editorTextFocus && suggestWidgetVisible"
}
这使得这3个特定跟随的经典VS C#完成行为成为可能 - 在我记住的时候,可以添加我想到的任何其他内容。
This enables the classic VS C# completion behavior for these 3 specific follow-on keys. Any others I will think of can be added as I remember them.
这篇关于可以将VS代码完成配置为接受关于标点符号的建议吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!