vs code的自动补全和智能提示通过减少输入量提升编码效率。1. 确保安装对应语言扩展以启用语言服务器;2. 在settings.json中配置触发字符、补全行为及参数提示等;3. 启用格式化保存、代码高亮等辅助功能优化体验。
VS Code的自动补全和智能提示,简单来说,就是让你的代码写得更快、更准,少犯错。它通过分析你的代码上下文,在你输入的时候,就能预测你可能想要输入的内容,省去你敲完整单词的时间。配置得当,效率提升不是一点点。
解决方案
VS Code的自动补全功能是开箱即用的,但要让它真正智能起来,需要一些配置。
- 确认语言支持: 确保你安装了对应编程语言的扩展。比如写python,就要装Python扩展。这些扩展通常会自带语言服务器,提供更高级的补全和提示。
- 设置触发字符: VS Code默认会在你输入.、(等字符时触发补全。你可以在settings.json里自定义触发字符。例如,你想在输入$时也触发补全,可以这样设置:
"editor.wordBasedSuggestions": false, "[html]": { "editor.quickSuggestions": true }, "[javascript]": { "editor.quickSuggestions": { "strings": true } }, "emmet.triggerExpansionOnTab": true, "editor.snippetSuggestions": "top", "javascript.suggest.enabled": true, "typescript.suggest.enabled": true, "editor.suggestOnTriggerCharacters": true, "editor.parameterHints.enabled": true, "files.autoSave": "afterDelay", "files.autoSaveDelay": 1000, "window.zoomLevel": 0, "workbench.colorTheme": "One Dark Pro", "security.workspace.trust.untrustedFiles": "open", "editor.fontSize": 16, "editor.fontFamily": "Cascadia Code", "editor.fontLigatures": true, "terminal.integrated.fontSize": 14, "workbench.iconTheme": "material-icon-theme", "breadcrumbs.enabled": false, "editor.minimap.enabled": false, "editor.renderWhitespace": "none", "editor.renderControlCharacters": false, "editor.guides.bracketPairs": false, "editor.inlineSuggest.enabled": true, "github.copilot.enable": { "*": true, "yaml": false, "plaintext": false, "markdown": true, "scminput": false }, "diffEditor.ignoreTrimWhitespace": false, "editor.formatOnSave": true, "editor.defaultFormatter": "esbenp.prettier-vscode", "eslint.alwaysShowStatus": true, "prettier.printWidth": 120, "window.titleBarStyle": "custom", "workbench.productIconTheme": "material-product-icons", "workbench.editor.enablePreview": false, "workbench.list.smoothScrolling": true, "editor.smoothScrolling": true, "editor.cursorSmoothCaretAnimation": true, "editor.stickyScroll.enabled": true, "editor.tabSize": 4, "liveServer.settings.donotShowInfoMsg": true, "liveServer.settings.donotVerifyTags": true, "editor.linkedEditing": true, "editor.codeActionsOnSave": { "source.fixAll.eslint": true }, "git.autofetch": true, "git.confirmSync": false, "update.mode": "manual", "window.menuBarVisibility": "toggle", "zenMode.hideLineNumbers": false, "zenMode.hideStatusBar": false, "zenMode.hideActivityBar": false, "zenMode.hidePanel": false, "editor.formatOnPaste": true, "editor.guides.indentation": false, "terminal.integrated.gpuAcceleration": "off", "editor.suggestSelection": "first", "vsintellicode.modify.editor.suggestSelection": "automaticallyOverrodeDefaultValue", "editor.acceptSuggestionOnEnter": "off", "files.trimTrailingWhitespace": true, "files.insertFinalNewline": true, "editor.trimAutoWhitespace": true, "editor.detectIndentation": false, "editor.insertSpaces": true, "editor.codeActionsOnSaveTimeout": 1000, "editor.guides.highlightActiveIndentation": false, "workbench.editor.decorations.colors": false, "editor.foldingStrategy": "indentation", "javascript.format.enable": false, "typescript.format.enable": false, "editor.bracketPairColorization.enabled": false, "editor.guides.activeIndentGuide": false, "editor.occurrencesHighlight": false, "editor.selectionHighlight": false, "editor.semanticHighlighting.enabled": false, "editor.inlayHints.enabled": "offUnlessPressed", "window.commandCenter": false, "workbench.layoutControl.enabled": false, "editor.lineNumbers": "relative", "workbench.activityBar.location": "top", "editor.stickyScroll.scrollWithEditor": true, "editor.padding.top": 10, "editor.padding.bottom": 10, "editor.cursorBlinking": "smooth", "editor.cursorStyle": "line", "workbench.editor.untitled.hint": "hidden", "editor.unicodeHighlight.nonBasicASCII": false, "workbench.editor.unfocused.border": false, "window.density.compact": true, "terminal.integrated.persistentSessionReviveProcess": "never", "terminal.integrated.tabs.enabled": true, "editor.find.seedSearchStringFromSelection": "never", "terminal.integrated.enablePersistentSessions": false, "editor.renderLineHighlight": "gutter", "editor.renderValidationDecorations": "off", "editor.hover.sticky": true, "editor.hover.above": true, "explorer.compactFolders": false, "workbench.editor.highlightModifiedTabs": true, "editor.foldingHighlight": false, "editor.foldingImportsByDefault": true, "terminal.integrated.defaultProfile.windows": "Git Bash", "terminal.integrated.profiles.windows": { "Git Bash": { "source": "Git Bash" } }, "files.exclude": { "**/.git": true, "**/.svn": true, "**/.hg": true, "**/CVS": true, "**/.DS_Store": true, "**/Thumbs.db": true, "**/node_modules": true }, "editor.minimap.renderCharacters": false, "editor.guides.highlightActiveBracketPair": false, "editor.matchBrackets": "never", "editor.guides.bracketPairsHorizontal": "never", "editor.guides.highlightActiveIndentation": false, "workbench.colorCustomizations": { "[One Dark Pro]": { "sideBar.background": "#282c34", "sideBarSectionHeader.background": "#282c34", "activityBar.background": "#282c34", "editorGroupHeader.tabsBackground": "#282c34", "tab.inactiveBackground": "#282c34", "tab.border": "#282c34", "tab.activeBorder": "#61afef", "editor.background": "#282c34", "editor.lineHighlightBackground": "#2c313a", "editorCursor.foreground": "#ffffff", "statusBar.background": "#282c34", "statusBar.debuggingBackground": "#282c34", "statusBar.noFolderBackground": "#282c34", "statusBar.border": "#282c34", "statusBarItem.remoteBackground": "#282c34", "statusBarItem.remoteForeground": "#61afef", "statusBarItem.hoverBackground": "#2c313a", "statusBarItem.activeBackground": "#2c313a", "statusBarItem.prominentBackground": "#2c313a", "statusBarItem.prominentHoverBackground": "#2c313a", "statusBarItem.prominentActiveBackground": "#2c313a", "activityBarBadge.background": "#61afef", "activityBarBadge.foreground": "#ffffff", "activityBar.foreground": "#61afef", "activityBar.inactiveForeground": "#61afef", "activityBar.border": "#282c34", "sideBar.border": "#282c34", "editorGroupHeader.border": "#282c34", "editorGroup.border": "#282c34", "panel.background": "#282c34", "panel.border": "#282c34", "panelTitle.activeBorder": "#61afef", "panelTitle.inactiveForeground": "#61afef", "panelTitle.activeForeground": "#61afef", "terminal.background": "#282c34", "terminal.foreground": "#abb2bf", "terminalCursor.foreground": "#ffffff", "terminal.border": "#282c34", "terminal.selectionBackground": "#2c313a", "terminal.ansiBlack": "#282c34", "terminal.ansired": "#e06c75", "terminal.ansiGreen": "#98c379", "terminal.ansiYellow": "#e5c07b", "terminal.ansiBlue": "#61afef", "terminal.ansiMagenta": "#c678dd", "terminal.ansiCyan": "#56b6c2", "terminal.ansiWhite": "#abb2bf", "terminal.ansiBrightBlack": "#5c6370", "terminal.ansiBrightRed": "#e06c75", "terminal.ansiBrightGreen": "#98c379", "terminal.ansiBrightYellow": "#e5c07b", "terminal.ansiBrightBlue": "#61afef", "terminal.ansiBrightMagenta": "#c678dd", "terminal.ansiBrightCyan": "#56b6c2", "terminal.ansiBrightWhite": "#ffffff", "input.background": "#2c313a", "input.foreground": "#abb2bf", "input.border": "#282c34", "inputOption.activeBackground": "#61afef", "inputOption.activeBorder": "#61afef", "inputValidation.errorBackground": "#e06c75", "inputValidation.errorBorder": "#e06c75", "inputValidation.infoBackground": "#61afef", "inputValidation.infoBorder": "#61afef", "inputValidation.warningBackground": "#e5c07b", "inputValidation.warningBorder": "#e5c07b", "list.activeSelectionBackground": "#2c313a", "list.inactiveSelectionBackground": "#2c313a", "list.hoverBackground": "#2c313a", "list.focusBackground": "#2c313a", "list.invalidItemForeground": "#e06c75", "list.dropBackground": "#2c313a", "list.highlightForeground": "#61afef", "list.focusOutline": "#61afef", "list.activeSelectionForeground": "#61afef", "list.inactiveSelectionForeground": "#61afef", "peekView.border": "#282c34", "peekViewEditor.background": "#282c34", "peekViewTitle.background": "#282c34", "peekViewResult.background": "#282c34", "peekViewEditorGutter.background": "#282c34", "peekViewResult.selectionBackground": "#2c313a", "peekViewEditor.matchHighlightBackground": "#61afef", "peekViewResult.matchHighlightBackground": "#61afef", "peekViewTitleDescription.foreground": "#abb2bf", "peekViewTitleLabel.foreground": "#61afef", "merge.incomingHeaderBackground": "#98c379", "merge.incomingContentBackground": "#98c379", "merge.currentHeaderBackground": "#61afef", "merge.currentContentBackground": "#61afef", "merge.commonHeaderBackground": "#e5c07b", "merge.commonContentBackground": "#e5c07b", "diffEditor.insertedLineBackground": "#98c379", "diffEditor.removedLineBackground": "#e06c75", "diffEditor.insertedTextBackground": "#98c379", "diffEditor.removedTextBackground": "#e06c75", "notificationCenterHeader.background": "#282c34", "notificationToast.background": "#282c34", "notificationCenter.border": "#282c34", "notificationToast.border": "#282c34", "notificationLink.foreground": "#61afef", "dropdown.background": "#282c34", "dropdown.border": "#282c34", "dropdown.foreground": "#abb2bf", "scrollbar.shadow": "#282c34", "scrollbarSlider.background": "#282c34", "scrollbarSlider.hoverBackground": "#2c313a", "scrollbarSlider.activeBackground": "#2c313a", "widget.shadow": "#282c34", "debugToolBar.background": "#282c34", "debugIcon.breakpointForeground": "#e06c75", "debugIcon.breakpointDisabledForeground": "#5c6370", "debugIcon.breakpointCurrentStackframeForeground": "#61afef", "debugIcon.breakpointStackframeForeground": "#61afef", "debugIcon.breakpointUnverifiedForeground": "#5c6370", "debugConsole.infoForeground": "#61afef", "debugConsole.warningForeground": "#e5c07b", "debugConsole.errorForeground": "#e06c75", "debugConsole.sourceForeground": "#abb2bf", "debugConsole.tokenForeground": "#abb2bf", "editorSuggestWidget.background": "#282c34", "editorSuggestWidget.border": "#282c34", "editorSuggestWidget.foreground": "#abb2bf", "editorSuggestWidget.selectedBackground": "#2c313a", "editorSuggestWidget.highlightForeground": "#61afef", "editorHoverWidget.background": "#282c34", "editorHoverWidget.border": "#282c34", "editorWidget.background": "#282c34", "editorWidget.border": "#282c34", "titleBar.activeBackground": "#282c34", "titleBar.inactiveBackground": "#282c34", "titleBar.activeForeground": "#abb2bf", "titleBar.inactiveForeground": "#5c6370", "titleBar.border": "#282c34", "menu.background": "#282c34", "menu.border": "#282c34", "menu.foreground": "#abb2bf", "menu.selectionBackground": "#2c313a", "menu.selectionForeground": "#61afef", "menubar.selectionBackground": "#2c313a", "menubar.selectionForeground": "#61afef", "settings.headerForeground": "#61afef", "settings.modifiedItemIndicator": "#61afef", "settings.focusedRowBackground": "#2c313a", "breadcrumb.foreground": "#abb2bf", "breadcrumb.focusForeground": "#61afef", "breadcrumb.activeSelectionForeground": "#61afef", "breadcrumbPicker.background": "#282c34", "editorGutter.background": "#282c34", "editorRuler.foreground": "#5c6370", "editorLineNumber.foreground": "#5c6370", "editorActiveLineNumber.foreground": "#61afef", "editorIndentGuide.background": "#5c6370", "editorBracketMatch.border": "#61afef", "editorBracketMatch.background": "#2c313a", "editorBracketPairGuide.activeBackground1": "#61afef", "editorBracketPairGuide.activeBackground2": "#61afef", "editorBracketPairGuide.activeBackground3": "#61afef", "editorBracketPairGuide.activeBackground4": "#61afef", "editorBracketPairGuide.activeBackground5": "#61afef", "editorBracketPairGuide.activeBackground6": "#61afef", "editorBracketPairGuide.background1": "#5c6370", "editorBracketPairGuide.background2": "#5c6370", "editorBracketPairGuide.background3": "#5c6370", "editorBracketPairGuide.background4": "#5c6370", "editorBracketPairGuide.background5": "#5c6370", "editorBracketPairGuide.background6": "#5c6370", "editorOverviewRuler.border": "#282c34", "editorOverviewRuler.findMatchForeground": "#61afef", "editorOverviewRuler.rangeHighlightForeground": "#61afef", "editorOverviewRuler.selectionHighlightForeground": "#61afef", "editorOverviewRuler.wordHighlightForeground": "#61afef", "editorOverviewRuler.wordHighlightStrongForeground": "#61afef", "editorOverviewRuler.modifiedForeground": "#61afef", "editorOverviewRuler.addedForeground": "#61afef", "editorOverviewRuler.deletedForeground": "#61afef", "editorOverviewRuler.errorForeground": "#e06c75", "editorOverviewRuler.warningForeground": "#e5c07b", "editorOverviewRuler.infoForeground": "#61afef", "editorOverviewRuler.bracketMatchForeground": "#61afef", "editorOverviewRuler.bracketPairGuideForeground": "#61afef", "editorOverviewRuler.rangeHighlightBackground": "#2c313a", "editorOverviewRuler.selectionHighlightBackground": "#2c313a", "editorOverviewRuler.wordHighlightBackground": "#2c313a", "editorOverviewRuler.wordHighlightStrongBackground": "#2c313a", "editorOverviewRuler.modifiedBackground": "#2c313a", "editorOverviewRuler.addedBackground": "#2c313a", "editorOverviewRuler.deletedBackground": "#2c313a", "editorOverviewRuler.errorBackground": "#2c313a", "editorOverviewRuler.warningBackground": "#2c313a", "editorOverviewRuler.infoBackground": "#2c313a", "editorOverviewRuler.bracketMatchBackground": "#2c313a", "editorOverviewRuler.bracketPairGuideBackground": "#2c313a", "textLink.foreground": "#61afef", "textCodeBlock.background": "#2c313a", "textPreformat.foreground": "#abb2bf", "textSeparator.foreground": "#5c6370", "button.background": "#61afef", "button.foreground": "#ffffff", "button.hoverBackground": "#2c313a", "checkbox.background": "#282c34", "checkbox.border": "#282c34", "checkbox.foreground": "#abb2bf", "progress.background": "#61afef", "badge.background": "#61afef", "badge.foreground": "#ffffff", "sideBarTitle.foreground": "#61afef", "sideBarSectionHeader.foreground": "#61afef", "sideBarSectionHeader.border": "#282c34", "sideBySideEditor.verticalSeparatorBackground": "#282c34", "sideBySideEditor.horizontalSeparatorBackground": "#282c34", "imagePreview.border": "#282c34", "audioPreview.border": "#282c34", "videoPreview.border": "#282c34", "markdown.blockquoteBackground": "#2c313a", "markdown.blockquoteBorder": "#61afef", "markdown.codeSpanBackground": "#2c313a", "markdown.codeSpanBorder": "#282c34", "markdown.emphasisForeground": "#61afef", "markdown.strongForeground": "#61afef", "markdown.linkForeground": "#61afef", "markdown.linkHoverForeground": "#61afef", "markdown.list.invalidItemForeground": "#e06c75", "markdown.list.itemBorder": "#282c34", "markdown.tableBorder": "#282c34", "markdown.tableOddRowsBackground": "#2c313a", "searchEditor.textInputBorder": "#282c34", "editorGroup.emptyBackground": "#282c34", "editorGroup.focusedEmptyBorder": "#61afef", "editorGroup.dropBackground": "#2c313a", "editorGroup.dropIntoPromptBackground": "#2c313a", "editorGroup.dropIntoPromptBorder": "#61afef", "editorGroup.dropIntoPromptForeground": "#61afef", "editorGroupHeader.tabsBorder": "#282c34", "tab.inactiveForeground": "#5c6370", "tab.activeForeground": "#61afef", "tab.hoverBackground": "#2c313a", "tab.hoverBorder": "#61afef", "tab.unfocusedActiveForeground": "#5c6370", "tab.unfocusedInactiveForeground": "#5c6370", "tab.unfocusedActiveBorder": "#5c6370", "tab.unfocusedInactiveBorder": "#5c6370", "editorCursor.blockBackground": "#282c34", "editorCursor.blockBorder": "#282c34", "editor.inactiveSelectionBackground": "#2c313a", "editorWhitespace.foreground": "#5c6370", "editorIndentGuide.activeBackground": "#61afef", "editorInlayHint.background": "#2c313a", "editorInlayHint.foreground": "#61afef", "editorInlayHint.typeForeground": "#61afef", "editorInlayHint.parameterForeground": "#61afef", "editorOverviewRuler.currentContentForeground": "#61afef", "editorOverviewRuler.incomingContentForeground": "#61afef", "editorOverviewRuler.commonContentForeground": "#61afef", "editorOverviewRuler.currentContentBackground": "#2c313a", "editorOverviewRuler.incomingContentBackground": "#2c313a", "editorOverviewRuler.commonContentBackground": "#2c313a", "editorSuggestWidget.focusHighlightForeground": "#61afef", "editorSuggestWidget.selectedForeground": "#61afef", "editorSuggestWidget.selectedIconForeground": "#61afef", "editorSuggestWidget.iconForeground": "#61afef", "editorGhostText.foreground": "#5c6370", "editorGhostText.background": "#282c34", "editorGhostText.border": "#282c34", "notebook.cellBorderColor": "#282c34", "notebook.cellEditorBackground": "#282c34", "notebook.cellHoverBackground": "#2c313a", "notebook.cellInsertionIndicator": "#61afef", "notebook.cellStatusBarItemHoverBackground": "#2c31
© 版权声明
文章版权归作者所有,未经允许请勿转载。
THE END