javascript 前端 typescript VS Code —— 介绍如何配置快捷代码片段和一些自用插件 - json, release-tasks

📅 2026-11-30 👤 拼多多助力营销技巧 📂 拼多多助力 👁️ 402 次阅读

VS Code —— 介绍如何配置快捷代码片段和一些自用插件

《工欲善其事,必先利其器》—— 既然点进来了,麻烦你看下去,希望你有不一样的收获~

一、配置代码片段

打开 VS Code,输入快捷键 Ctrl + Shift + p,打开面板:

紧接着输入 snippets 关键词,搜索代码片段的配置项,Enter 回车,然后我们选择,新建全局代码片段文件(如果像我那样已经存在文件的,可以直接选择编辑):

新建(或编辑)之后你会发现,上面有一段注释是教你怎么写代码片段的:

我们可以在这个文件里,根据示例,配置自己想要的代码片段,这里我也直接提供给大家,可以直接复制、保存。大家也可以根据模板配置其他代码片段:

"a vue2 snippet": {

"prefix": "vue2",

"body": [

"",

"",

"",

"",

""

],

"description": "a vue2 snippet"

},

"a vue3 snippet": {

"prefix": "vue3",

"body": [

"",

"",

"",

"",

""

],

"description": "a vue3 snippet"

},

"a vue3 snippet with typescript": {

"prefix": "vue3-ts",

"body": [

"", 拼多多帮助力入口

"",

"",

"",

""

],

"description": "a vue3 snippet with typescript"

}

这样就配置完了。

二、快捷应用

之后我们随便找一个 vue 文件测试一下,输入 vue,会有相应的提示:

是不是瞬间感觉舒服了起来~

三、一些自用插件

这里就简单推荐一下自己本人日常开发中使用的 VS Code 插件吧,大家有需要的可以拿走,理性做个参考就行了哈~

Any-rule:正则表达式插件Auto Close Tag:自动匹配标签Auto Rename Tag:自动重命名标签Auto Import:自动引入文件Bracket Pair Colorization:彩色括号标识Code Runner:代码运行插件Carbon-now-sh:生成代码块截图插件Code Spell Checker:代码拼写检测EditorConfig for VS Code:这个就不用多说了吧ESLintElement-ui-helper:这个是饿了么框架的辅助插件Git Lens:行代码溯源插件Git Graph:仓库图形化插件Git History:仓库提交历史插件Github Theme:编辑器主题Highlight Matching Tag:标签高亮标识Import Cost:引入文件计算大小插件JavaScript code snippetsJavaScript and Typescript NightlyLive ServerMaterial Icon Theme:文件图标插件Open in browserPower Mode:输入字数统计插件Svelte for VS Code:svelte提示插件Tailwind CSS IntelliSense:tailwind框架提示插件TODO Highlight:待定高亮插件VolarVS Code Counter:代码量统计插件Version Lens:依赖包版本查看插件

四、File Nesting Config for VS Code

插件库搜索:File Nesting,认准 antfu 开发的插件,安装:

这玩意儿,配置完之后,非常的巴适!

打开 settings.json ,配置下面的选项:

"fileNestingUpdater.autoUpdate": true,

"fileNestingUpdater.autoUpdateInterval": 720,

"fileNestingUpdater.promptOnAutoUpdate": true,

"fileNestingUpdater.upstreamRepo": "antfu/vscode-file-nesting-config",

"fileNestingUpdater.upstreamBranch": "main",

"explorer.fileNesting.enabled": true,

"explorer.fileNesting.expand": false,

"explorer.fileNesting.patterns": {

"*.asax": "$(capture).*.cs, $(capture).*.vb",

"*.ascx": "$(capture).*.cs, $(capture).*.vb",

"*.ashx": "$(capture).*.cs, $(capture).*.vb",

"*.aspx": "$(capture).*.cs, $(capture).*.vb",

"*.bloc.dart": "$(capture).event.dart, $(capture).state.dart",

"*.c": "$(capture).h",

"*.cc": "$(capture).hpp, $(capture).h, $(capture).hxx",

"*.component.ts": "$(capture).component.html, $(capture).component.spec.ts, $(capture).component.css, $(capture).component.scss, $(capture).component.sass, $(capture).component.less",

"*.cpp": "$(capture).hpp, $(capture).h, $(capture).hxx",

"*.cs": "$(capture).*.cs",

"*.cshtml": "$(capture).cshtml.cs",

"*.csproj": "*.config, *proj.user, appsettings.*, bundleconfig.json",

"*.css": "$(capture).css.map, $(capture).*.css",

"*.cxx": "$(capture).hpp, $(capture).h, $(capture).hxx",

"*.dart": "$(capture).freezed.dart, $(capture).g.dart",

"*.ex": "$(capture).html.eex, $(capture).html.heex, $(capture).html.leex",

"*.go": "$(capture)_test.go",

"*.java": "$(capture).class",

"*.js": "$(capture).js.map, $(capture).*.js, $(capture)_*.js",

"*.jsx": "$(capture).js, $(capture).*.jsx, $(capture)_*.js, $(capture)_*.jsx",

"*.master": "$(capture).*.cs, $(capture).*.vb",

"*.module.ts": "$(capture).resolver.ts, $(capture).controller.ts, $(capture).service.ts",

"*.pubxml": "$(capture).pubxml.user",

"*.resx": "$(capture).*.resx, $(capture).designer.cs, $(capture).designer.vb",

"*.tex": "$(capture).acn, $(capture).acr, $(capture).alg, $(capture).aux, $(capture).bbl, $(capture).blg, $(capture).fdb_latexmk, $(capture).fls, $(capture).glg, $(capture).glo, $(capture).gls, $(capture).idx, $(capture).ind, $(capture).ist, $(capture).lof, $(capture).log, $(capture).lot, $(capture).out, $(capture).pdf, $(capture).synctex.gz, $(capture).toc, $(capture).xdv",

"*.ts": "$(capture).js, $(capture).d.ts.map, $(capture).*.ts, $(capture)_*.js, $(capture)_*.ts",

"*.tsx": "$(capture).ts, $(capture).*.tsx, $(capture)_*.ts, $(capture)_*.tsx",

"*.vbproj": "*.config, *proj.user, appsettings.*, bundleconfig.json",

"*.vue": "$(capture).*.ts, $(capture).*.js, $(capture).story.vue",

"*.xaml": "$(capture).xaml.cs",

"+layout.svelte": "+layout.ts,+layout.ts,+layout.js,+layout.server.ts,+layout.server.js",

"+page.svelte": "+page.server.ts,+page.server.js,+page.ts,+page.js ",

".clang-tidy": ".clang-format, .clangd, compile_commands.json",

".env": "*.env, .env.*, .envrc, env.d.ts",

".gitignore": ".gitattributes, .gitmodules, .gitmessage, .mailmap, .git-blame*",

".project": ".classpath",

"BUILD.bazel": "*.bzl, *.bazel, *.bazelrc, bazel.rc, .bazelignore, .bazelproject, WORKSPACE",

"CMakeLists.txt": "*.cmake, *.cmake.in, .cmake-format.yaml, CMakePresets.json",

"I*.cs": "$(capture).cs",

"artisan": "*.env, .babelrc*, .codecov, .cssnanorc*, .env.*, .envrc, .htmlnanorc*, .lighthouserc.*, .mocha*, .postcssrc*, .terserrc*, api-extractor.json, ava.config.*, babel.config.*, contentlayer.config.*, cssnano.config.*, cypress.*, env.d.ts, formkit.config.*, formulate.config.*, histoire.config.*, htmlnanorc.*, jasmine.*, jest.config.*, jsconfig.*, karma*, lighthouserc.*, playwright.config.*, postcss.config.*, puppeteer.config.*, server.php, svgo.config.*, tailwind.config.*, tsconfig.*, tsdoc.*, unocss.config.*, vitest.config.*, webpack.config.*, webpack.mix.js, windi.config.*",

"astro.config.*": "*.env, .babelrc*, .codecov, .cssnanorc*, .env.*, .envrc, .htmlnanorc*, .lighthouserc.*, .mocha*, .postcssrc*, .terserrc*, api-extractor.json, ava.config.*, babel.config.*, contentlayer.config.*, cssnano.config.*, cypress.*, env.d.ts, formkit.config.*, formulate.config.*, histoire.config.*, htmlnanorc.*, jasmine.*, jest.config.*, jsconfig.*, karma*, lighthouserc.*, playwright.config.*, postcss.config.*, puppeteer.config.*, svgo.config.*, tailwind.config.*, tsconfig.*, tsdoc.*, unocss.config.*, vitest.config.*, webpack.config.*, windi.config.*",

"cargo.toml": ".clippy.toml, .rustfmt.toml, cargo.lock, clippy.toml, cross.toml, rust-toolchain.toml, rustfmt.toml",

"composer.json": ".php*.cache, composer.lock, phpunit.xml*, psalm*.xml",

"default.nix": "shell.nix",

"deno.json*": "*.env, .env.*, .envrc, api-extractor.json, env.d.ts, import-map.json, import_map.json, jsconfig.*, tsconfig.*, tsdoc.*",

"dockerfile": ".dockerignore, docker-compose.*, dockerfile*",

"flake.nix": "flake.lock",

"gatsby-config.*": "*.env, .babelrc*, .codecov, .cssnanorc*, .env.*, .envrc, .htmlnanorc*, .lighthouserc.*, .mocha*, .postcssrc*, .terserrc*, api-extractor.json, ava.config.*, babel.config.*, contentlayer.config.*, cssnano.config.*, cypress.*, env.d.ts, formkit.config.*, formulate.config.*, gatsby-browser.*, gatsby-node.*, gatsby-ssr.*, gatsby-transformer.*, histoire.config.*, htmlnanorc.*, jasmine.*, jest.config.*, jsconfig.*, karma*, lighthouserc.*, playwright.config.*, postcss.config.*, puppeteer.config.*, svgo.config.*, tailwind.config.*, tsconfig.*, tsdoc.*, unocss.config.*, vitest.config.*, webpack.config.*, windi.config.*",

"gemfile": ".ruby-version, gemfile.lock",

"go.mod": ".air*, go.sum",

"go.work": "go.work.sum",

"mix.exs": ".credo.exs, .dialyzer_ignore.exs, .formatter.exs, .iex.exs, .tool-versions, mix.lock",

"next.config.*": "*.env, .babelrc*, .codecov, .cssnanorc*, .env.*, .envrc, .htmlnanorc*, .lighthouserc.*, .mocha*, .postcssrc*, .terserrc*, api-extractor.json, ava.config.*, babel.config.*, contentlayer.config.*, cssnano.config.*, cypress.*, env.d.ts, formkit.config.*, formulate.config.*, histoire.config.*, htmlnanorc.*, jasmine.*, jest.config.*, jsconfig.*, karma*, lighthouserc.*, next-env.d.ts, playwright.config.*, postcss.config.*, puppeteer.config.*, svgo.config.*, tailwind.config.*, tsconfig.*, tsdoc.*, unocss.config.*, vitest.config.*, webpack.config.*, windi.config.*",

"nuxt.config.*": "*.env, .babelrc*, .codecov, .cssnanorc*, .env.*, .envrc, .htmlnanorc*, .lighthouserc.*, .mocha*, .postcssrc*, .terserrc*, api-extractor.json, ava.config.*, babel.config.*, contentlayer.config.*, cssnano.config.*, cypress.*, env.d.ts, formkit.config.*, formulate.config.*, histoire.config.*, htmlnanorc.*, jasmine.*, jest.config.*, jsconfig.*, karma*, lighthouserc.*, playwright.config.*, postcss.config.*, puppeteer.config.*, svgo.config.*, tailwind.config.*, tsconfig.*, tsdoc.*, unocss.config.*, vitest.config.*, webpack.config.*, windi.config.*",

"package.json": ".browserslist*, .circleci*, .codecov, .commitlint*, .cz-config.js, .czrc, .dlint.json, .dprint.json, .editorconfig, .eslint*, .firebase*, .flowconfig, .github*, .gitlab*, .gitpod*, .huskyrc*, .jslint*, .lighthouserc.*, .lintstagedrc*, .markdownlint*, .mocha*, .node-version, .nodemon*, .npm*, .nvmrc, .pm2*, .pnp.*, .pnpm*, .prettier*, .releaserc*, .sentry*, .stackblitz*, .styleci*, .stylelint*, .tazerc*, .textlint*, .tool-versions, .travis*, .versionrc*, .vscode*, .watchman*, .xo-config*, .yamllint*, .yarnrc*, Procfile, apollo.config.*, appveyor*, ava.config.*, azure-pipelines*, bower.json, build.config.*, commitlint*, crowdin*, cypress.*, dangerfile*, dlint.json, dprint.json, firebase.json, grunt*, gulp*, histoire.config.*, jasmine.*, jenkins*, jest.config.*, karma*, lerna*, lighthouserc.*, lint-staged*, nest-cli.*, netlify*, nodemon*, nx.*, package-lock.json, package.nls*.json, phpcs.xml, playwright.config.*, pm2.*, pnpm*, prettier*, pullapprove*, puppeteer.config.*, pyrightconfig.json, release-tasks.sh, renovate*, rollup.config.*, stylelint*, tslint*, tsup.config.*, turbo*, typedoc*, unlighthouse*, vercel*, vetur.config.*, vitest.config.*, webpack*, workspace.json, xo.config.*, yarn*",

"pubspec.yaml": ".metadata, .packages, all_lint_rules.yaml, analysis_options.yaml, build.yaml, pubspec.lock, pubspec_overrides.yaml",

"pyproject.toml": ".pdm.toml, pdm.lock, pyproject.toml",

"quasar.conf.js": "*.env, .babelrc*, .codecov, .cssnanorc*, .env.*, .envrc, .htmlnanorc*, .lighthouserc.*, .mocha*, .postcssrc*, .terserrc*, api-extractor.json, ava.config.*, babel.config.*, contentlayer.config.*, cssnano.config.*, cypress.*, env.d.ts, formkit.config.*, formulate.config.*, histoire.config.*, htmlnanorc.*, jasmine.*, jest.config.*, jsconfig.*, karma*, lighthouserc.*, playwright.config.*, postcss.config.*, puppeteer.config.*, quasar.extensions.json, svgo.config.*, tailwind.config.*, tsconfig.*, tsdoc.*, unocss.config.*, vitest.config.*, webpack.config.*, windi.config.*",

"readme*": "authors, backers*, changelog*, citation*, code_of_conduct*, codeowners, contributing*, contributors, copying, credits, governance.md, history.md, license*, maintainers, readme*, security.md, sponsors*",

"remix.config.*": "*.env, .babelrc*, .codecov, .cssnanorc*, .env.*, .envrc, .htmlnanorc*, .lighthouserc.*, .mocha*, .postcssrc*, .terserrc*, api-extractor.json, ava.config.*, babel.config.*, contentlayer.config.*, cssnano.config.*, cypress.*, env.d.ts, formkit.config.*, formulate.config.*, histoire.config.*, htmlnanorc.*, jasmine.*, jest.config.*, jsconfig.*, karma*, lighthouserc.*, playwright.config.*, postcss.config.*, puppeteer.config.*, remix.*, svgo.config.*, tailwind.config.*, tsconfig.*, tsdoc.*, unocss.config.*, vitest.config.*, webpack.config.*, windi.config.*",

"rush.json": ".browserslist*, .circleci*, .codecov, .commitlint*, .cz-config.js, .czrc, .dlint.json, .dprint.json, .editorconfig, .eslint*, .firebase*, .flowconfig, .github*, .gitlab*, .gitpod*, .huskyrc*, .jslint*, .lighthouserc.*, .lintstagedrc*, .markdownlint*, .mocha*, .node-version, .nodemon*, .npm*, .nvmrc, .pm2*, .pnp.*, .pnpm*, .prettier*, .releaserc*, .sentry*, .stackblitz*, .styleci*, .stylelint*, .tazerc*, .textlint*, .tool-versions, .travis*, .versionrc*, .vscode*, .watchman*, .xo-config*, .yamllint*, .yarnrc*, Procfile, apollo.config.*, appveyor*, ava.config.*, azure-pipelines*, bower.json, build.config.*, commitlint*, crowdin*, cypress.*, dangerfile*, dlint.json, dprint.json, firebase.json, grunt*, gulp*, histoire.config.*, jasmine.*, jenkins*, jest.config.*, karma*, lerna*, lighthouserc.*, lint-staged*, nest-cli.*, netlify*, nodemon*, nx.*, package-lock.json, package.nls*.json, phpcs.xml, playwright.config.*, pm2.*, pnpm*, prettier*, pullapprove*, puppeteer.config.*, pyrightconfig.json, release-tasks.sh, renovate*, rollup.config.*, stylelint*, tslint*, tsup.config.*, turbo*, typedoc*, unlighthouse*, vercel*, vetur.config.*, vitest.config.*, webpack*, workspace.json, xo.config.*, yarn*",

"shims.d.ts": "*.d.ts",

"svelte.config.*": "*.env, .babelrc*, .codecov, .cssnanorc*, .env.*, .envrc, .htmlnanorc*, .lighthouserc.*, .mocha*, .postcssrc*, .terserrc*, api-extractor.json, ava.config.*, babel.config.*, contentlayer.config.*, cssnano.config.*, cypress.*, env.d.ts, formkit.config.*, formulate.config.*, histoire.config.*, htmlnanorc.*, jasmine.*, jest.config.*, jsconfig.*, karma*, lighthouserc.*, mdsvex.config.js, playwright.config.*, postcss.config.*, puppeteer.config.*, svgo.config.*, tailwind.config.*, tsconfig.*, tsdoc.*, unocss.config.*, vitest.config.*, webpack.config.*, windi.config.*",

"vite.config.*": "*.env, .babelrc*, .codecov, .cssnanorc*, .env.*, .envrc, .htmlnanorc*, .lighthouserc.*, .mocha*, .postcssrc*, .terserrc*, api-extractor.json, ava.config.*, babel.config.*, contentlayer.config.*, cssnano.config.*, cypress.*, env.d.ts, formkit.config.*, formulate.config.*, histoire.config.*, htmlnanorc.*, jasmine.*, jest.config.*, jsconfig.*, karma*, lighthouserc.*, playwright.config.*, postcss.config.*, puppeteer.config.*, svgo.config.*, tailwind.config.*, tsconfig.*, tsdoc.*, unocss.config.*, vitest.config.*, webpack.config.*, windi.config.*",

"vue.config.*": "*.env, .babelrc*, .codecov, .cssnanorc*, .env.*, .envrc, .htmlnanorc*, .lighthouserc.*, .mocha*, .postcssrc*, .terserrc*, api-extractor.json, ava.config.*, babel.config.*, contentlayer.config.*, cssnano.config.*, cypress.*, env.d.ts, formkit.config.*, formulate.config.*, histoire.config.*, htmlnanorc.*, jasmine.*, jest.config.*, jsconfig.*, karma*, lighthouserc.*, playwright.config.*, postcss.config.*, puppeteer.config.*, svgo.config.*, tailwind.config.*, tsconfig.*, tsdoc.*, unocss.config.*, vitest.config.*, webpack.config.*, windi.config.*"

},

虽然有点多,但是可以拯救你的项目目录不再混乱!效果如下:

整体效果就是这样,希望你会喜欢哟。感谢你的阅读,愿你的未来一片光明~

好文阅读

标签: 拼多多助力网站平台 赚钱项目 拼多多助力网 首码项目 手赚APP
拼多多助力营销技巧