乐闻世界logo
搜索文章和话题

What are VSCode IntelliSense features?

2月18日 18:28

VSCode IntelliSense provides intelligent code completion, parameter information, quick info and member lists, greatly improving coding efficiency.

IntelliSense Basics

Triggering IntelliSense

  • Manual Trigger: Ctrl+Space
  • Auto Trigger: Automatically display when typing
  • Context Trigger: Automatically display in specific contexts

IntelliSense Types

  • Code Completion: Auto-complete variables, functions, classes, etc.
  • Parameter Info: Display function parameters
  • Quick Info: Display type and documentation information
  • Member List: Display object members

Code Completion

Basic Completion

javascript
// Type partial code, IntelliSense automatically shows suggestions console. // Shows all methods of console object // Press Tab or Enter to accept suggestion console.log('Hello World');

Smart Suggestions

  • Context-based suggestions
  • Prioritize most relevant suggestions
  • Support fuzzy matching

Completion Configuration

json
{ "editor.quickSuggestions": { "other": true, "comments": false, "strings": false }, "editor.suggestOnTriggerCharacters": true, "editor.acceptSuggestionOnEnter": "on", "editor.tabCompletion": "on" }

Parameter Information

Viewing Parameter Info

  • Shortcut: Ctrl+Shift+Space
  • Function: Display function parameter types and documentation
  • Navigation: Use up/down arrows to switch overloads

Parameter Info Example

javascript
// Type function name then press Ctrl+Shift+Space Math.max( // Shows parameter info: number1: number, number2: number, ...values: number[]

Quick Info

Viewing Quick Info

  • Shortcut: Ctrl+K, Ctrl+I
  • Function: Display symbol type and documentation
  • Hover: Hover mouse over symbol

Quick Info Example

javascript
// Hover over function name function greet(name) { return `Hello, ${name}!`; } // Shows: function greet(name: string): string

Member List

Viewing Member List

  • Trigger: Type . after object name
  • Function: Display all members of object
  • Filter: Type characters to filter list

Member List Example

javascript
const obj = { name: 'John', age: 25, greet() { return `Hello, ${this.name}!`; } }; obj. // Shows name, age, greet and other members

IntelliSense Configuration

Basic Configuration

json
{ "editor.quickSuggestions": { "other": true, "comments": false, "strings": false }, "editor.suggest.showStatusBar": true, "editor.suggest.maxVisibleSuggestions": 12, "editor.suggest.selectionMode": "always" }

Advanced Configuration

json
{ "editor.suggest.localityBonus": true, "editor.suggest.shareSuggestSelections": true, "editor.suggest.snippetsPreventQuickSuggestions": false, "editor.wordBasedSuggestions": true }

Language-specific Configuration

JavaScript/TypeScript

json
{ "[javascript]": { "editor.quickSuggestions": { "other": true, "comments": false, "strings": true } }, "[typescript]": { "editor.quickSuggestions": { "other": true, "comments": false, "strings": true } } }

Python

json
{ "[python]": { "editor.quickSuggestions": { "other": true, "comments": false, "strings": false } } }

IntelliSense Extensions

Installing Language Servers

  • TypeScript: Built-in support
  • Python: Pylance extension
  • Go: Go extension
  • Rust: rust-analyzer extension

Configuring Language Servers

json
{ "typescript.suggest.autoImports": true, "python.analysis.autoImportCompletions": true, "go.useLanguageServer": true }

Important Notes

  • IntelliSense depends on language servers
  • Large projects may affect performance
  • Regularly update language servers
  • Reasonably configure completion trigger conditions
  • Use code snippets to improve efficiency
标签:VSCode