This question is particularly pointed at other C# devs coming over to TypeScript in VS Code.
I fell in love with the code completion in VS C#. To illustrate, say I'm trying to write:
console.log('hello')
Using C#, I would have:
console.
console.log('')
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 ?
One can implement this oneself using the macros extension. To do this:
Install the macros extension
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": "="}}
]
}
}
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"
}
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With