6

I'm pretty new to Visual studio code. I am using Visual studio code for AngularJS application development. As I am from a .NET development background, I'm much fond of intellisense feature in visual studio code. But I could feel something is missing in this. When I type any Object name, autocomplete box pops up with suggestion, when I select the respective item and press period, the object name is not complete. Example: assume the object name is SampleObject. When I start typing "Sam", suggestion pop up lists "SampleObject". Once I select this name and press period, the output is "Sam." and not as "SampleObject." Any setting has to be added for the expected behaviour? Your help is much appreciated.

Thanks.

Sakthirajesh N
  • 181
  • 1
  • 7

2 Answers2

12

I posted the same query in VScode git hub issues forum. I got the following reply.

You can add the snippet below to your keyboard shortcut configuration to the VS Code to accept a suggestion and insert the dot when pressing .

{
    "key": ".",
    "command": "^acceptSelectedSuggestion",
    "when": "editorTextFocus && suggestWidgetVisible && suggestionSupportsAcceptOnKey && editorLangId == 'javascript'"
}

This worked.

Julius Babies
  • 955
  • 3
  • 6
  • 22
Sakthirajesh N
  • 181
  • 1
  • 7
  • More information on Visual Studio Code keyboard shortcuts can be found here: https://code.visualstudio.com/docs/customization/keybindings#_customizing-shortcuts – dotarj Nov 21 '16 at 12:05
  • Added the same for "space" (also consistent with visual studio). I don't see any reason to include `suggestionSupportsAcceptOnKey` or `editorLangId == 'javascript'` either; just do it, dammit. – dudeNumber4 Nov 04 '19 at 19:47
0

VSCode 1.51 (Oct. 2020) will make those choices more visible with:

Status bar for suggestions

The suggestions control can now also show its own status bar at the bottom of the window.
Enable it using the editor.suggestStatusBar.enable setting.
It makes toggling details simpler, and shows if a completion supports inserting, replacing, or both.

Suggest Status Bar -- https://media.githubusercontent.com/media/microsoft/vscode-docs/b90c7662cebb51d859506135a03f1ff459f1c743/release-notes/images/1_51/suggest-status.png

Theme: GitHub Light, Font: FiraCode

In the sample above, selecting "Insert" results in Math.floorceil and selecting "Replace" results in Math.floor.

The new editor.suggest.insertMode setting allows you to configure whether you prefer insert or replace.
When a suggestion supports both, your preference will be the default.

Note that you also have the setting editor.tabCompletion to force "replace" to be the default, instead of "insert".

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250