Docs Menu
Docs Home
/
MongoDB for VS Code
/

Enable Autocomplete for String Literals

On this page

  • About this Task
  • Before you Begin
  • Steps
  • Learn More

You can optionally enable autocomplete for string literals inside VSCode. Enabling autocomplete for string literals lets you automatically populate database and collection names when using use("") or db.getCollection("") syntax within a MongoDB playground.

  • Enabling autocomplete for string literals is a global VSCode setting. Changing this setting may affect the behavior and performance of other extensions and of VSCode itself.

  • If you do not want to enable autocomplete for string literals inside VSCode, you can use the keyboard shortcut Ctrl + Space. This shortcut prompts autocomplete for string literals in your MongoDB playground.

Install the MongoDB VSCode extension.

1

In VSCode, open the command palette:

Operating System
Keyboard Command
Windows
CTRL + SHIFT + P
MacOS
CMD + SHIFT + P

Enter Open User Settings (JSON) and select the option from the autocompleted list:

Image of a stream connection
click to enlarge
2

Copy the following code snippet:

"editor.quickSuggestions": {
"other": true,
"comments": false,
"strings": true
}

Paste the code into the Settings.json file:

Image of a stream connection
click to enlarge
3

In a new playground file connected to your deployment, type the first character of a collection name between db.getCollection("") and click the full name to populate the collection name:

Get collection autocomplete
click to enlarge

You can also autocomplete database names by typing the first character of a database name in-between the use("") statement.

Back

Run Aggregation Pipelines