Làm cách nào để tắt khoảng cách tự động trong python?

IntelliSense là một thuật ngữ chung cho các tính năng chỉnh sửa mã khác nhau bao gồm. hoàn thành mã, thông tin tham số, thông tin nhanh và danh sách thành viên. Các tính năng của IntelliSense đôi khi được gọi bằng các tên khác như "hoàn thành mã", "hỗ trợ nội dung" và "gợi ý mã. "

IntelliSense cho ngôn ngữ lập trình của bạn

Visual Studio Code IntelliSense được cung cấp cho JavaScript, TypeScript, JSON, HTML, CSS, SCSS và Ít hơn. Mã VS hỗ trợ hoàn thành dựa trên từ cho bất kỳ ngôn ngữ lập trình nào nhưng cũng có thể được định cấu hình để có IntelliSense phong phú hơn bằng cách cài đặt tiện ích mở rộng ngôn ngữ

Dưới đây là các tiện ích mở rộng ngôn ngữ phổ biến nhất trên Thị trường. Chọn một ô tiện ích mở rộng bên dưới để đọc mô tả và đánh giá nhằm quyết định tiện ích mở rộng nào phù hợp nhất với bạn

Tính năng IntelliSense

Các tính năng VS Code IntelliSense được hỗ trợ bởi một dịch vụ ngôn ngữ. Dịch vụ ngôn ngữ cung cấp khả năng hoàn thành mã thông minh dựa trên ngữ nghĩa ngôn ngữ và phân tích mã nguồn của bạn. Nếu một dịch vụ ngôn ngữ biết các cách hoàn thành có thể, các đề xuất IntelliSense sẽ bật lên khi bạn nhập. Nếu bạn tiếp tục gõ các ký tự, danh sách các thành viên [biến, phương thức, v.v. ] được lọc để chỉ bao gồm các thành viên chứa các ký tự đã nhập của bạn. Nhấn Tab hoặc Enter sẽ chèn thành viên đã chọn.

Bạn có thể kích hoạt IntelliSense trong bất kỳ cửa sổ trình chỉnh sửa nào bằng cách nhập ⌃Space [Windows, Linux Ctrl+ . ] or by typing a trigger character [such as the dot character [. ] bằng JavaScript].

Mẹo. Tiện ích đề xuất hỗ trợ lọc CamelCase, nghĩa là bạn có thể nhập các chữ cái viết hoa trong tên phương thức để giới hạn các đề xuất. Ví dụ: "cra" sẽ nhanh chóng hiển thị "createApplication"

Nếu muốn, bạn có thể tắt IntelliSense trong khi nhập. Xem bên dưới để tìm hiểu cách tắt hoặc tùy chỉnh các tính năng IntelliSense của VS Code

Do dịch vụ ngôn ngữ cung cấp, bạn có thể xem thông tin nhanh cho từng phương pháp bằng cách nhấn ⌃Dấu cách [Windows, Linux Ctrl+Space] or clicking the info icon. The accompanying documentation for the method will now expand to the side. The expanded documentation will stay so and will update as you navigate the list. You can close this by pressing ⌃Dấu cách [Windows, Linux Ctrl+Dấu cách] again or by clicking on the close icon.

Sau khi chọn một phương pháp, bạn được cung cấp thông tin tham số

Khi áp dụng, một dịch vụ ngôn ngữ sẽ hiển thị các loại cơ bản trong chữ ký phương thức và thông tin nhanh. Trong hình trên, bạn có thể thấy một số loại

[
  {
    "key": "ctrl+space",
    "command": "editor.action.triggerSuggest",
    "when": "editorHasCompletionItemProvider && editorTextFocus && !editorReadonly"
  },
  {
    "key": "ctrl+space",
    "command": "toggleSuggestionDetails",
    "when": "editorTextFocus && suggestWidgetVisible"
  },
  {
    "key": "ctrl+alt+space",
    "command": "toggleSuggestionFocus",
    "when": "editorTextFocus && suggestWidgetVisible"
  }
]
2. Vì JavaScript là động và không cần hoặc không bắt buộc các loại, nên
[
  {
    "key": "ctrl+space",
    "command": "editor.action.triggerSuggest",
    "when": "editorHasCompletionItemProvider && editorTextFocus && !editorReadonly"
  },
  {
    "key": "ctrl+space",
    "command": "toggleSuggestionDetails",
    "when": "editorTextFocus && suggestWidgetVisible"
  },
  {
    "key": "ctrl+alt+space",
    "command": "toggleSuggestionFocus",
    "when": "editorTextFocus && suggestWidgetVisible"
  }
]
2 gợi ý rằng biến có thể thuộc bất kỳ loại nào

Các loại hoàn thành

Mã JavaScript bên dưới minh họa các lần hoàn thành IntelliSense. IntelliSense cung cấp cả đề xuất được phỏng đoán và số nhận dạng toàn cầu của dự án. Các ký hiệu được suy luận được trình bày trước tiên, tiếp theo là các mã định danh chung [được hiển thị bằng biểu tượng Word]

VS Code IntelliSense cung cấp các loại hoàn thành khác nhau, bao gồm đề xuất máy chủ ngôn ngữ, đoạn trích và hoàn thành văn bản dựa trên từ đơn giản

IconNameKiểu biểu tượngPhương thức và Hàm_______14,
[
  {
    "key": "ctrl+space",
    "command": "editor.action.triggerSuggest",
    "when": "editorHasCompletionItemProvider && editorTextFocus && !editorReadonly"
  },
  {
    "key": "ctrl+space",
    "command": "toggleSuggestionDetails",
    "when": "editorTextFocus && suggestWidgetVisible"
  },
  {
    "key": "ctrl+alt+space",
    "command": "toggleSuggestionFocus",
    "when": "editorTextFocus && suggestWidgetVisible"
  }
]
5,
[
  {
    "key": "ctrl+space",
    "command": "editor.action.triggerSuggest",
    "when": "editorHasCompletionItemProvider && editorTextFocus && !editorReadonly"
  },
  {
    "key": "ctrl+space",
    "command": "toggleSuggestionDetails",
    "when": "editorTextFocus && suggestWidgetVisible"
  },
  {
    "key": "ctrl+alt+space",
    "command": "toggleSuggestionFocus",
    "when": "editorTextFocus && suggestWidgetVisible"
  }
]
6Biến
[
  {
    "key": "ctrl+space",
    "command": "editor.action.triggerSuggest",
    "when": "editorHasCompletionItemProvider && editorTextFocus && !editorReadonly"
  },
  {
    "key": "ctrl+space",
    "command": "toggleSuggestionDetails",
    "when": "editorTextFocus && suggestWidgetVisible"
  },
  {
    "key": "ctrl+alt+space",
    "command": "toggleSuggestionFocus",
    "when": "editorTextFocus && suggestWidgetVisible"
  }
]
7Trường
[
  {
    "key": "ctrl+space",
    "command": "editor.action.triggerSuggest",
    "when": "editorHasCompletionItemProvider && editorTextFocus && !editorReadonly"
  },
  {
    "key": "ctrl+space",
    "command": "toggleSuggestionDetails",
    "when": "editorTextFocus && suggestWidgetVisible"
  },
  {
    "key": "ctrl+alt+space",
    "command": "toggleSuggestionFocus",
    "when": "editorTextFocus && suggestWidgetVisible"
  }
]
8Tham số loại
[
  {
    "key": "ctrl+space",
    "command": "editor.action.triggerSuggest",
    "when": "editorHasCompletionItemProvider && editorTextFocus && !editorReadonly"
  },
  {
    "key": "ctrl+space",
    "command": "toggleSuggestionDetails",
    "when": "editorTextFocus && suggestWidgetVisible"
  },
  {
    "key": "ctrl+alt+space",
    "command": "toggleSuggestionFocus",
    "when": "editorTextFocus && suggestWidgetVisible"
  }
]
9Constants
[
  {
    "key": "ctrl+space",
    "command": "editor.action.triggerSuggest",
    "when": "editorHasCompletionItemProvider && editorTextFocus && !editorReadonly"
  },
  {
    "key": "ctrl+space",
    "command": "toggleSuggestionDetails",
    "when": "editorTextFocus && suggestWidgetVisible"
  },
  {
    "key": "ctrl+alt+space",
    "command": "toggleSuggestionFocus",
    "when": "editorTextFocus && suggestWidgetVisible"
  }
]
0Classes
[
  {
    "key": "ctrl+space",
    "command": "editor.action.triggerSuggest",
    "when": "editorHasCompletionItemProvider && editorTextFocus && !editorReadonly"
  },
  {
    "key": "ctrl+space",
    "command": "toggleSuggestionDetails",
    "when": "editorTextFocus && suggestWidgetVisible"
  },
  {
    "key": "ctrl+alt+space",
    "command": "toggleSuggestionFocus",
    "when": "editorTextFocus && suggestWidgetVisible"
  }
]
1Interfaces
[
  {
    "key": "ctrl+space",
    "command": "editor.action.triggerSuggest",
    "when": "editorHasCompletionItemProvider && editorTextFocus && !editorReadonly"
  },
  {
    "key": "ctrl+space",
    "command": "toggleSuggestionDetails",
    "when": "editorTextFocus && suggestWidgetVisible"
  },
  {
    "key": "ctrl+alt+space",
    "command": "toggleSuggestionFocus",
    "when": "editorTextFocus && suggestWidgetVisible"
  }
]
2Structures
[
  {
    "key": "ctrl+space",
    "command": "editor.action.triggerSuggest",
    "when": "editorHasCompletionItemProvider && editorTextFocus && !editorReadonly"
  },
  {
    "key": "ctrl+space",
    "command": "toggleSuggestionDetails",
    "when": "editorTextFocus && suggestWidgetVisible"
  },
  {
    "key": "ctrl+alt+space",
    "command": "toggleSuggestionFocus",
    "when": "editorTextFocus && suggestWidgetVisible"
  }
]
3Events
[
  {
    "key": "ctrl+space",
    "command": "editor.action.triggerSuggest",
    "when": "editorHasCompletionItemProvider && editorTextFocus && !editorReadonly"
  },
  {
    "key": "ctrl+space",
    "command": "toggleSuggestionDetails",
    "when": "editorTextFocus && suggestWidgetVisible"
  },
  {
    "key": "ctrl+alt+space",
    "command": "toggleSuggestionFocus",
    "when": "editorTextFocus && suggestWidgetVisible"
  }
]
4Operators
[
  {
    "key": "ctrl+space",
    "command": "editor.action.triggerSuggest",
    "when": "editorHasCompletionItemProvider && editorTextFocus && !editorReadonly"
  },
  {
    "key": "ctrl+space",
    "command": "toggleSuggestionDetails",
    "when": "editorTextFocus && suggestWidgetVisible"
  },
  {
    "key": "ctrl+alt+space",
    "command": "toggleSuggestionFocus",
    "when": "editorTextFocus && suggestWidgetVisible"
  }
]
5Modules
[
  {
    "key": "ctrl+space",
    "command": "editor.action.triggerSuggest",
    "when": "editorHasCompletionItemProvider && editorTextFocus && !editorReadonly"
  },
  {
    "key": "ctrl+space",
    "command": "toggleSuggestionDetails",
    "when": "editorTextFocus && suggestWidgetVisible"
  },
  {
    "key": "ctrl+alt+space",
    "command": "toggleSuggestionFocus",
    "when": "editorTextFocus && suggestWidgetVisible"
  }
]
6Properties and Attributes
[
  {
    "key": "ctrl+space",
    "command": "editor.action.triggerSuggest",
    "when": "editorHasCompletionItemProvider && editorTextFocus && !editorReadonly"
  },
  {
    "key": "ctrl+space",
    "command": "toggleSuggestionDetails",
    "when": "editorTextFocus && suggestWidgetVisible"
  },
  {
    "key": "ctrl+alt+space",
    "command": "toggleSuggestionFocus",
    "when": "editorTextFocus && suggestWidgetVisible"
  }
]
7Values and Enumerations
[
  {
    "key": "ctrl+space",
    "command": "editor.action.triggerSuggest",
    "when": "editorHasCompletionItemProvider && editorTextFocus && !editorReadonly"
  },
  {
    "key": "ctrl+space",
    "command": "toggleSuggestionDetails",
    "when": "editorTextFocus && suggestWidgetVisible"
  },
  {
    "key": "ctrl+alt+space",
    "command": "toggleSuggestionFocus",
    "when": "editorTextFocus && suggestWidgetVisible"
  }
]
8,
[
  {
    "key": "ctrl+space",
    "command": "editor.action.triggerSuggest",
    "when": "editorHasCompletionItemProvider && editorTextFocus && !editorReadonly"
  },
  {
    "key": "ctrl+space",
    "command": "toggleSuggestionDetails",
    "when": "editorTextFocus && suggestWidgetVisible"
  },
  {
    "key": "ctrl+alt+space",
    "command": "toggleSuggestionFocus",
    "when": "editorTextFocus && suggestWidgetVisible"
  }
]
9References
[
  {
    "key": "ctrl+space",
    "command": "editor.action.triggerSuggest",
    "when": "editorHasCompletionItemProvider && editorTextFocus && !editorReadonly"
  },
  {
    "key": "ctrl+space",
    "command": "toggleSuggestionDetails",
    "when": "editorTextFocus && suggestWidgetVisible"
  },
  {
    "key": "ctrl+alt+space",
    "command": "toggleSuggestionFocus",
    "when": "editorTextFocus && suggestWidgetVisible"
  }
]
20Keywords
[
  {
    "key": "ctrl+space",
    "command": "editor.action.triggerSuggest",
    "when": "editorHasCompletionItemProvider && editorTextFocus && !editorReadonly"
  },
  {
    "key": "ctrl+space",
    "command": "toggleSuggestionDetails",
    "when": "editorTextFocus && suggestWidgetVisible"
  },
  {
    "key": "ctrl+alt+space",
    "command": "toggleSuggestionFocus",
    "when": "editorTextFocus && suggestWidgetVisible"
  }
]
21Files
[
  {
    "key": "ctrl+space",
    "command": "editor.action.triggerSuggest",
    "when": "editorHasCompletionItemProvider && editorTextFocus && !editorReadonly"
  },
  {
    "key": "ctrl+space",
    "command": "toggleSuggestionDetails",
    "when": "editorTextFocus && suggestWidgetVisible"
  },
  {
    "key": "ctrl+alt+space",
    "command": "toggleSuggestionFocus",
    "when": "editorTextFocus && suggestWidgetVisible"
  }
]
22Folders
[
  {
    "key": "ctrl+space",
    "command": "editor.action.triggerSuggest",
    "when": "editorHasCompletionItemProvider && editorTextFocus && !editorReadonly"
  },
  {
    "key": "ctrl+space",
    "command": "toggleSuggestionDetails",
    "when": "editorTextFocus && suggestWidgetVisible"
  },
  {
    "key": "ctrl+alt+space",
    "command": "toggleSuggestionFocus",
    "when": "editorTextFocus && suggestWidgetVisible"
  }
]
23Colors
[
  {
    "key": "ctrl+space",
    "command": "editor.action.triggerSuggest",
    "when": "editorHasCompletionItemProvider && editorTextFocus && !editorReadonly"
  },
  {
    "key": "ctrl+space",
    "command": "toggleSuggestionDetails",
    "when": "editorTextFocus && suggestWidgetVisible"
  },
  {
    "key": "ctrl+alt+space",
    "command": "toggleSuggestionFocus",
    "when": "editorTextFocus && suggestWidgetVisible"
  }
]
24Unit
[
  {
    "key": "ctrl+space",
    "command": "editor.action.triggerSuggest",
    "when": "editorHasCompletionItemProvider && editorTextFocus && !editorReadonly"
  },
  {
    "key": "ctrl+space",
    "command": "toggleSuggestionDetails",
    "when": "editorTextFocus && suggestWidgetVisible"
  },
  {
    "key": "ctrl+alt+space",
    "command": "toggleSuggestionFocus",
    "when": "editorTextFocus && suggestWidgetVisible"
  }
]
25Snippet prefixes
[
  {
    "key": "ctrl+space",
    "command": "editor.action.triggerSuggest",
    "when": "editorHasCompletionItemProvider && editorTextFocus && !editorReadonly"
  },
  {
    "key": "ctrl+space",
    "command": "toggleSuggestionDetails",
    "when": "editorTextFocus && suggestWidgetVisible"
  },
  {
    "key": "ctrl+alt+space",
    "command": "toggleSuggestionFocus",
    "when": "editorTextFocus && suggestWidgetVisible"
  }
]
26Words
[
  {
    "key": "ctrl+space",
    "command": "editor.action.triggerSuggest",
    "when": "editorHasCompletionItemProvider && editorTextFocus && !editorReadonly"
  },
  {
    "key": "ctrl+space",
    "command": "toggleSuggestionDetails",
    "when": "editorTextFocus && suggestWidgetVisible"
  },
  {
    "key": "ctrl+alt+space",
    "command": "toggleSuggestionFocus",
    "when": "editorTextFocus && suggestWidgetVisible"
  }
]
27

Tùy chỉnh IntelliSense

Bạn có thể tùy chỉnh trải nghiệm IntelliSense của mình trong phần cài đặt và liên kết phím

Cài đặt

Các cài đặt hiển thị bên dưới là cài đặt mặc định. Bạn có thể thay đổi các cài đặt này trong tệp

[
  {
    "key": "ctrl+space",
    "command": "editor.action.triggerSuggest",
    "when": "editorHasCompletionItemProvider && editorTextFocus && !editorReadonly"
  },
  {
    "key": "ctrl+space",
    "command": "toggleSuggestionDetails",
    "when": "editorTextFocus && suggestWidgetVisible"
  },
  {
    "key": "ctrl+alt+space",
    "command": "toggleSuggestionFocus",
    "when": "editorTextFocus && suggestWidgetVisible"
  }
]
28 của mình như được mô tả trong Cài đặt không gian làm việc và người dùng

[
  {
    "key": "ctrl+space",
    "command": "editor.action.triggerSuggest",
    "when": "editorHasCompletionItemProvider && editorTextFocus && !editorReadonly"
  },
  {
    "key": "ctrl+space",
    "command": "toggleSuggestionDetails",
    "when": "editorTextFocus && suggestWidgetVisible"
  },
  {
    "key": "ctrl+alt+space",
    "command": "toggleSuggestionFocus",
    "when": "editorTextFocus && suggestWidgetVisible"
  }
]
0

Hoàn thành tab

Trình chỉnh sửa hỗ trợ "hoàn thành tab" sẽ chèn hoàn thành phù hợp nhất khi nhấn Tab . Điều này hoạt động bất kể tiện ích đề xuất có hiển thị hay không. Ngoài ra, nhấn Tab sau khi chèn đề xuất sẽ chèn đề xuất tốt nhất tiếp theo.

Theo mặc định, tính năng hoàn thành tab bị tắt. Sử dụng cài đặt

[
  {
    "key": "ctrl+space",
    "command": "editor.action.triggerSuggest",
    "when": "editorHasCompletionItemProvider && editorTextFocus && !editorReadonly"
  },
  {
    "key": "ctrl+space",
    "command": "toggleSuggestionDetails",
    "when": "editorTextFocus && suggestWidgetVisible"
  },
  {
    "key": "ctrl+alt+space",
    "command": "toggleSuggestionFocus",
    "when": "editorTextFocus && suggestWidgetVisible"
  }
]
29 để bật nó. Những giá trị này tồn tại

  • [
      {
        "key": "ctrl+space",
        "command": "editor.action.triggerSuggest",
        "when": "editorHasCompletionItemProvider && editorTextFocus && !editorReadonly"
      },
      {
        "key": "ctrl+space",
        "command": "toggleSuggestionDetails",
        "when": "editorTextFocus && suggestWidgetVisible"
      },
      {
        "key": "ctrl+alt+space",
        "command": "toggleSuggestionFocus",
        "when": "editorTextFocus && suggestWidgetVisible"
      }
    ]
    
    20 - [mặc định] Tính năng hoàn thành tab bị tắt
  • [
      {
        "key": "ctrl+space",
        "command": "editor.action.triggerSuggest",
        "when": "editorHasCompletionItemProvider && editorTextFocus && !editorReadonly"
      },
      {
        "key": "ctrl+space",
        "command": "toggleSuggestionDetails",
        "when": "editorTextFocus && suggestWidgetVisible"
      },
      {
        "key": "ctrl+alt+space",
        "command": "toggleSuggestionFocus",
        "when": "editorTextFocus && suggestWidgetVisible"
      }
    ]
    
    21 - Tính năng hoàn thành tab được bật cho tất cả các đề xuất và các yêu cầu lặp lại chèn đề xuất tốt nhất tiếp theo
  • [
      {
        "key": "ctrl+space",
        "command": "editor.action.triggerSuggest",
        "when": "editorHasCompletionItemProvider && editorTextFocus && !editorReadonly"
      },
      {
        "key": "ctrl+space",
        "command": "toggleSuggestionDetails",
        "when": "editorTextFocus && suggestWidgetVisible"
      },
      {
        "key": "ctrl+alt+space",
        "command": "toggleSuggestionFocus",
        "when": "editorTextFocus && suggestWidgetVisible"
      }
    ]
    
    22 - Hoàn thành tab chỉ chèn đoạn mã tĩnh có tiền tố khớp với tiền tố dòng hiện tại

Tiền thưởng địa phương

Việc sắp xếp các đề xuất tùy thuộc vào thông tin mở rộng và mức độ phù hợp của chúng với từ hiện tại bạn đang nhập. Ngoài ra, bạn có thể yêu cầu trình chỉnh sửa tăng các đề xuất xuất hiện gần vị trí con trỏ hơn, bằng cách sử dụng cài đặt

[
  {
    "key": "ctrl+space",
    "command": "editor.action.triggerSuggest",
    "when": "editorHasCompletionItemProvider && editorTextFocus && !editorReadonly"
  },
  {
    "key": "ctrl+space",
    "command": "toggleSuggestionDetails",
    "when": "editorTextFocus && suggestWidgetVisible"
  },
  {
    "key": "ctrl+alt+space",
    "command": "toggleSuggestionFocus",
    "when": "editorTextFocus && suggestWidgetVisible"
  }
]
23

Trong các hình ảnh trên, bạn có thể thấy rằng

[
  {
    "key": "ctrl+space",
    "command": "editor.action.triggerSuggest",
    "when": "editorHasCompletionItemProvider && editorTextFocus && !editorReadonly"
  },
  {
    "key": "ctrl+space",
    "command": "toggleSuggestionDetails",
    "when": "editorTextFocus && suggestWidgetVisible"
  },
  {
    "key": "ctrl+alt+space",
    "command": "toggleSuggestionFocus",
    "when": "editorTextFocus && suggestWidgetVisible"
  }
]
24,
[
  {
    "key": "ctrl+space",
    "command": "editor.action.triggerSuggest",
    "when": "editorHasCompletionItemProvider && editorTextFocus && !editorReadonly"
  },
  {
    "key": "ctrl+space",
    "command": "toggleSuggestionDetails",
    "when": "editorTextFocus && suggestWidgetVisible"
  },
  {
    "key": "ctrl+alt+space",
    "command": "toggleSuggestionFocus",
    "when": "editorTextFocus && suggestWidgetVisible"
  }
]
25 và
[
  {
    "key": "ctrl+space",
    "command": "editor.action.triggerSuggest",
    "when": "editorHasCompletionItemProvider && editorTextFocus && !editorReadonly"
  },
  {
    "key": "ctrl+space",
    "command": "toggleSuggestionDetails",
    "when": "editorTextFocus && suggestWidgetVisible"
  },
  {
    "key": "ctrl+alt+space",
    "command": "toggleSuggestionFocus",
    "when": "editorTextFocus && suggestWidgetVisible"
  }
]
26 được sắp xếp dựa trên phạm vi mà chúng xuất hiện [vòng lặp, chức năng, tệp]

lựa chọn gợi ý

Theo mặc định, VS Code chọn trước gợi ý đầu tiên trong danh sách gợi ý. Ví dụ: nếu bạn muốn hành vi khác để luôn chọn mục được sử dụng gần đây nhất trong danh sách đề xuất, bạn có thể sử dụng cài đặt

[
  {
    "key": "ctrl+space",
    "command": "editor.action.triggerSuggest",
    "when": "editorHasCompletionItemProvider && editorTextFocus && !editorReadonly"
  },
  {
    "key": "ctrl+space",
    "command": "toggleSuggestionDetails",
    "when": "editorTextFocus && suggestWidgetVisible"
  },
  {
    "key": "ctrl+alt+space",
    "command": "toggleSuggestionFocus",
    "when": "editorTextFocus && suggestWidgetVisible"
  }
]
27

Các giá trị

[
  {
    "key": "ctrl+space",
    "command": "editor.action.triggerSuggest",
    "when": "editorHasCompletionItemProvider && editorTextFocus && !editorReadonly"
  },
  {
    "key": "ctrl+space",
    "command": "toggleSuggestionDetails",
    "when": "editorTextFocus && suggestWidgetVisible"
  },
  {
    "key": "ctrl+alt+space",
    "command": "toggleSuggestionFocus",
    "when": "editorTextFocus && suggestWidgetVisible"
  }
]
27 có sẵn là

  • [
      {
        "key": "ctrl+space",
        "command": "editor.action.triggerSuggest",
        "when": "editorHasCompletionItemProvider && editorTextFocus && !editorReadonly"
      },
      {
        "key": "ctrl+space",
        "command": "toggleSuggestionDetails",
        "when": "editorTextFocus && suggestWidgetVisible"
      },
      {
        "key": "ctrl+alt+space",
        "command": "toggleSuggestionFocus",
        "when": "editorTextFocus && suggestWidgetVisible"
      }
    ]
    
    29 - [mặc định] Luôn chọn mục trên cùng của danh sách
  • [
      {
        "key": "ctrl+space",
        "command": "editor.action.triggerSuggest",
        "when": "editorHasCompletionItemProvider && editorTextFocus && !editorReadonly"
      },
      {
        "key": "ctrl+space",
        "command": "toggleSuggestionDetails",
        "when": "editorTextFocus && suggestWidgetVisible"
      },
      {
        "key": "ctrl+alt+space",
        "command": "toggleSuggestionFocus",
        "when": "editorTextFocus && suggestWidgetVisible"
      }
    ]
    
    40 - Mục đã sử dụng trước đó được chọn trừ khi tiền tố [loại để chọn] chọn một mục khác
  • [
      {
        "key": "ctrl+space",
        "command": "editor.action.triggerSuggest",
        "when": "editorHasCompletionItemProvider && editorTextFocus && !editorReadonly"
      },
      {
        "key": "ctrl+space",
        "command": "toggleSuggestionDetails",
        "when": "editorTextFocus && suggestWidgetVisible"
      },
      {
        "key": "ctrl+alt+space",
        "command": "toggleSuggestionFocus",
        "when": "editorTextFocus && suggestWidgetVisible"
      }
    ]
    
    41 - Chọn các mục dựa trên các tiền tố trước đó đã hoàn thành các đề xuất đó

Việc chọn mục được sử dụng gần đây nhất rất hữu ích vì bạn có thể nhanh chóng chèn cùng một nội dung hoàn thành nhiều lần

"Nhập để chọn" có nghĩa là tiền tố hiện tại [đại khái là văn bản bên trái của con trỏ] được sử dụng để lọc và sắp xếp các đề xuất. Khi điều này xảy ra và khi kết quả của nó khác với kết quả của

[
  {
    "key": "ctrl+space",
    "command": "editor.action.triggerSuggest",
    "when": "editorHasCompletionItemProvider && editorTextFocus && !editorReadonly"
  },
  {
    "key": "ctrl+space",
    "command": "toggleSuggestionDetails",
    "when": "editorTextFocus && suggestWidgetVisible"
  },
  {
    "key": "ctrl+alt+space",
    "command": "toggleSuggestionFocus",
    "when": "editorTextFocus && suggestWidgetVisible"
  }
]
40, nó sẽ được ưu tiên

Khi sử dụng tùy chọn cuối cùng,

[
  {
    "key": "ctrl+space",
    "command": "editor.action.triggerSuggest",
    "when": "editorHasCompletionItemProvider && editorTextFocus && !editorReadonly"
  },
  {
    "key": "ctrl+space",
    "command": "toggleSuggestionDetails",
    "when": "editorTextFocus && suggestWidgetVisible"
  },
  {
    "key": "ctrl+alt+space",
    "command": "toggleSuggestionFocus",
    "when": "editorTextFocus && suggestWidgetVisible"
  }
]
41, Mã VS ghi nhớ mục nào đã được chọn cho một tiền tố cụ thể [một phần văn bản]. Ví dụ: nếu bạn nhập
[
  {
    "key": "ctrl+space",
    "command": "editor.action.triggerSuggest",
    "when": "editorHasCompletionItemProvider && editorTextFocus && !editorReadonly"
  },
  {
    "key": "ctrl+space",
    "command": "toggleSuggestionDetails",
    "when": "editorTextFocus && suggestWidgetVisible"
  },
  {
    "key": "ctrl+alt+space",
    "command": "toggleSuggestionFocus",
    "when": "editorTextFocus && suggestWidgetVisible"
  }
]
44 rồi chọn
[
  {
    "key": "ctrl+space",
    "command": "editor.action.triggerSuggest",
    "when": "editorHasCompletionItemProvider && editorTextFocus && !editorReadonly"
  },
  {
    "key": "ctrl+space",
    "command": "toggleSuggestionDetails",
    "when": "editorTextFocus && suggestWidgetVisible"
  },
  {
    "key": "ctrl+alt+space",
    "command": "toggleSuggestionFocus",
    "when": "editorTextFocus && suggestWidgetVisible"
  }
]
45, lần sau khi bạn nhập
[
  {
    "key": "ctrl+space",
    "command": "editor.action.triggerSuggest",
    "when": "editorHasCompletionItemProvider && editorTextFocus && !editorReadonly"
  },
  {
    "key": "ctrl+space",
    "command": "toggleSuggestionDetails",
    "when": "editorTextFocus && suggestWidgetVisible"
  },
  {
    "key": "ctrl+alt+space",
    "command": "toggleSuggestionFocus",
    "when": "editorTextFocus && suggestWidgetVisible"
  }
]
44, gợi ý
[
  {
    "key": "ctrl+space",
    "command": "editor.action.triggerSuggest",
    "when": "editorHasCompletionItemProvider && editorTextFocus && !editorReadonly"
  },
  {
    "key": "ctrl+space",
    "command": "toggleSuggestionDetails",
    "when": "editorTextFocus && suggestWidgetVisible"
  },
  {
    "key": "ctrl+alt+space",
    "command": "toggleSuggestionFocus",
    "when": "editorTextFocus && suggestWidgetVisible"
  }
]
45 sẽ được chọn trước. Điều này cho phép bạn nhanh chóng ánh xạ các tiền tố khác nhau tới các đề xuất khác nhau, ví dụ:
[
  {
    "key": "ctrl+space",
    "command": "editor.action.triggerSuggest",
    "when": "editorHasCompletionItemProvider && editorTextFocus && !editorReadonly"
  },
  {
    "key": "ctrl+space",
    "command": "toggleSuggestionDetails",
    "when": "editorTextFocus && suggestWidgetVisible"
  },
  {
    "key": "ctrl+alt+space",
    "command": "toggleSuggestionFocus",
    "when": "editorTextFocus && suggestWidgetVisible"
  }
]
44 ->
[
  {
    "key": "ctrl+space",
    "command": "editor.action.triggerSuggest",
    "when": "editorHasCompletionItemProvider && editorTextFocus && !editorReadonly"
  },
  {
    "key": "ctrl+space",
    "command": "toggleSuggestionDetails",
    "when": "editorTextFocus && suggestWidgetVisible"
  },
  {
    "key": "ctrl+alt+space",
    "command": "toggleSuggestionFocus",
    "when": "editorTextFocus && suggestWidgetVisible"
  }
]
45 và
[
  {
    "key": "ctrl+space",
    "command": "editor.action.triggerSuggest",
    "when": "editorHasCompletionItemProvider && editorTextFocus && !editorReadonly"
  },
  {
    "key": "ctrl+space",
    "command": "toggleSuggestionDetails",
    "when": "editorTextFocus && suggestWidgetVisible"
  },
  {
    "key": "ctrl+alt+space",
    "command": "toggleSuggestionFocus",
    "when": "editorTextFocus && suggestWidgetVisible"
  }
]
50 ->
[
  {
    "key": "ctrl+space",
    "command": "editor.action.triggerSuggest",
    "when": "editorHasCompletionItemProvider && editorTextFocus && !editorReadonly"
  },
  {
    "key": "ctrl+space",
    "command": "toggleSuggestionDetails",
    "when": "editorTextFocus && suggestWidgetVisible"
  },
  {
    "key": "ctrl+alt+space",
    "command": "toggleSuggestionFocus",
    "when": "editorTextFocus && suggestWidgetVisible"
  }
]
51

Đoạn trích trong đề xuất

Theo mặc định, Mã VS hiển thị các đoạn trích và đề xuất hoàn thành trong một tiện ích con. Bạn có thể kiểm soát hành vi bằng cài đặt

[
  {
    "key": "ctrl+space",
    "command": "editor.action.triggerSuggest",
    "when": "editorHasCompletionItemProvider && editorTextFocus && !editorReadonly"
  },
  {
    "key": "ctrl+space",
    "command": "toggleSuggestionDetails",
    "when": "editorTextFocus && suggestWidgetVisible"
  },
  {
    "key": "ctrl+alt+space",
    "command": "toggleSuggestionFocus",
    "when": "editorTextFocus && suggestWidgetVisible"
  }
]
52. Để xóa đoạn trích khỏi tiện ích đề xuất, hãy đặt giá trị thành
[
  {
    "key": "ctrl+space",
    "command": "editor.action.triggerSuggest",
    "when": "editorHasCompletionItemProvider && editorTextFocus && !editorReadonly"
  },
  {
    "key": "ctrl+space",
    "command": "toggleSuggestionDetails",
    "when": "editorTextFocus && suggestWidgetVisible"
  },
  {
    "key": "ctrl+alt+space",
    "command": "toggleSuggestionFocus",
    "when": "editorTextFocus && suggestWidgetVisible"
  }
]
53. Nếu muốn xem các đoạn trích, bạn có thể chỉ định thứ tự liên quan đến các đề xuất; . Mặc định là
[
  {
    "key": "ctrl+space",
    "command": "editor.action.triggerSuggest",
    "when": "editorHasCompletionItemProvider && editorTextFocus && !editorReadonly"
  },
  {
    "key": "ctrl+space",
    "command": "toggleSuggestionDetails",
    "when": "editorTextFocus && suggestWidgetVisible"
  },
  {
    "key": "ctrl+alt+space",
    "command": "toggleSuggestionFocus",
    "when": "editorTextFocus && suggestWidgetVisible"
  }
]
56

Tổ hợp phím

Các ràng buộc chính được hiển thị bên dưới là các ràng buộc chính mặc định. Bạn có thể thay đổi những điều này trong tệp

[
  {
    "key": "ctrl+space",
    "command": "editor.action.triggerSuggest",
    "when": "editorHasCompletionItemProvider && editorTextFocus && !editorReadonly"
  },
  {
    "key": "ctrl+space",
    "command": "toggleSuggestionDetails",
    "when": "editorTextFocus && suggestWidgetVisible"
  },
  {
    "key": "ctrl+alt+space",
    "command": "toggleSuggestionFocus",
    "when": "editorTextFocus && suggestWidgetVisible"
  }
]
58 của mình như được mô tả trong Key Bindings

Ghi chú. Có nhiều liên kết chính khác liên quan đến IntelliSense. Mở Phím tắt mặc định [Tệp > Tùy chọn > Phím tắt] và tìm kiếm "gợi ý"

[
  {
    "key": "ctrl+space",
    "command": "editor.action.triggerSuggest",
    "when": "editorHasCompletionItemProvider && editorTextFocus && !editorReadonly"
  },
  {
    "key": "ctrl+space",
    "command": "toggleSuggestionDetails",
    "when": "editorTextFocus && suggestWidgetVisible"
  },
  {
    "key": "ctrl+alt+space",
    "command": "toggleSuggestionFocus",
    "when": "editorTextFocus && suggestWidgetVisible"
  }
]

Xử lý sự cố

Nếu bạn thấy IntelliSense đã ngừng hoạt động, dịch vụ ngôn ngữ có thể không chạy. Hãy thử khởi động lại Mã VS và điều này sẽ giải quyết vấn đề. Nếu bạn vẫn thiếu các tính năng của IntelliSense sau khi cài đặt tiện ích mở rộng ngôn ngữ, hãy mở một sự cố trong kho lưu trữ của tiện ích mở rộng ngôn ngữ

Mẹo. Để định cấu hình và khắc phục sự cố JavaScript IntelliSense, hãy xem

Một phần mở rộng ngôn ngữ cụ thể có thể không hỗ trợ tất cả các tính năng VS Code IntelliSense. Xem lại README của tiện ích mở rộng để tìm hiểu những gì được hỗ trợ. Nếu bạn cho rằng có vấn đề với tiện ích mở rộng ngôn ngữ, bạn thường có thể tìm kho lưu trữ sự cố cho tiện ích mở rộng thông qua VS Code Marketplace. Điều hướng đến trang Chi tiết của tiện ích mở rộng và chọn liên kết Hỗ trợ

Bước tiếp theo

IntelliSense chỉ là một trong những tính năng mạnh mẽ của VS Code. Đọc để tìm hiểu thêm

  • JavaScript - Tận dụng tối đa quá trình phát triển JavaScript của bạn, bao gồm định cấu hình IntelliSense
  • Nút. js - Xem ví dụ về hoạt động của IntelliSense trong Nút. hướng dẫn js
  • Gỡ lỗi - Tìm hiểu cách thiết lập gỡ lỗi cho ứng dụng của bạn
  • Tạo tiện ích mở rộng Ngôn ngữ - Tìm hiểu cách tạo tiện ích mở rộng thêm IntelliSense cho các ngôn ngữ lập trình mới

Câu hỏi thường gặp

Tại sao tôi không nhận được bất kỳ lời đề nghị nào?

Điều này có thể được gây ra bởi nhiều lý do. Trước tiên, hãy thử khởi động lại Mã VS. Nếu sự cố vẫn tiếp diễn, hãy tham khảo tài liệu của phần mở rộng ngôn ngữ. Để khắc phục sự cố cụ thể về JavaScript, vui lòng xem

Tại sao tôi không nhìn thấy gợi ý phương pháp và biến?

Sự cố này là do thiếu các tệp khai báo kiểu [gõ] trong JavaScript. Bạn có thể kiểm tra xem gói tệp khai báo loại có sẵn cho một thư viện cụ thể hay không bằng cách sử dụng trang TypeSearch. Có thêm thông tin về vấn đề này trong. Đối với các ngôn ngữ khác, vui lòng tham khảo tài liệu của tiện ích mở rộng

Lệnh không gian trong Python là gì?

Hàm Chuỗi isspace[] của Python kiểm tra một chuỗi để tìm các ký tự khoảng trắng và chỉ trả về True nếu chuỗi đó chứa tất cả các ký tự khoảng cách , i. e. các loại dấu cách khác nhau [\n, \t, \r, \v, '']; .

Dòng mới trong Python là gì?

Ký tự dòng mới trong Python là \n . Nó được sử dụng để chỉ ra sự kết thúc của một dòng văn bản.

Chủ Đề