Table of Contents
Configuration formatting
Install eslint and prettier extensions
Commonly used plug-ins
Home Development Tools VSCode How to configure vue in VSCode and use Vetur language recognition engine!

How to configure vue in VSCode and use Vetur language recognition engine!

Oct 14, 2021 am 10:03 AM
vscode vue format

How to configure vue in VSCode? Identify vue syntax? The following article will introduce to you how to use Vetur as a language recognition engine. Let us create the best VSCode for vuers!

How to configure vue in VSCode and use Vetur language recognition engine!

After downloading vscode from the official website, the installation opens and you are prompted to install a Chinese language pack. Follow the prompts to install and restart, and the interface becomes a Chinese interface. [Recommended learning: "vscode tutorial"]

uses Materia Theme as the interface theme. The interface style is very clean, the colors are eye-friendly, and I feel good when writing code. Follow the refreshing~

icon display uses Material Icon Theme, the file icon is very complete, and it looks very good with Materia Theme

because I The vue technology stack is used, so it is necessary to identify the vue syntax. It is recommended to follow Vetur as the language recognition engine to provide syntax recognition, formatting, and related tips.

Configuration formatting

vetur comes with its own formatting tool and uses the prettier formatting scheme. For details, please see the configuration and use ctrl/command,Open settings

You can see that the js formatting engine uses prettier

by default, but it is recommended to use eslintunification for general projects Source code format, so vuter needs to be adapted to eslint

Install eslint and prettier extensions

Follow eslint Extension tip, to use eslint normally, you must also format it globally according to eslint

npm install -g eslint
Copy after login

. The following is my vscode custom settings

{
  "workbench.iconTheme": "eq-material-theme-icons",
  "workbench.colorTheme": "Material Theme",
  "materialTheme.fixIconsRunning": false,
  "editor.fontSize": 16, // 字体大小
  // 以下是代码格式化配置
  "editor.formatOnSave": true, // 每次保存的时候自动格式化
  "editor.tabSize": 2, // 代码缩进修改成2个空格
  "eslint.autoFixOnSave": false, // 每次保存的时候将代码按eslint格式进行修复
  "prettier.eslintIntegration": true, // 让prettier使用eslint的代码格式进行校验
  "prettier.semi": false, // 去掉代码结尾的分号
  "prettier.singleQuote": true, // 使用带引号替代双引号
  "javascript.format.insertSpaceBeforeFunctionParenthesis": true, // 让函数(名)和后面的括号之间加个空格
  "vetur.format.defaultFormatter.html": "js-beautify-html", //格式化.vue中html
  "vetur.format.defaultFormatter.js": "vscode-typescript", //让vue中的js按编辑器自带的ts格式进行格式化
  "vetur.format.defaultFormatterOptions": {
    "js-beautify-html": {
      "wrap_attributes": "force-aligned" //属性强制折行对齐
    }
  },
  "eslint.validate": [
    //开启对.vue文件中错误的检查
    "javascript",
    "javascriptreact",
    {
      "language": "html",
      "autoFix": true
    },
    {
      "language": "vue",
      "autoFix": true
    }
  ]
}
Copy after login

Every time I save Formatting, liberating labor, the effect is as follows

Commonly used plug-ins

  • Auto Rename Tag When changing the tag name, automatically change the name of the closed tag
  • Bookmarks Bookmark plug-in, record key points of the code, easier to get the corresponding points during review
  • Bracket Pair Colorizer Bracket coloring, for multiple embedded The set of brackets corresponds to accurate identification
  • Change Case When declaring code variables, you can switch existing variables to camel case, constant, or other styles
  • Codelf I get angry when I talk about code naming. Half of the programming time is spent thinking about how to name it more appropriately and appropriately. With this artifact, although it cannot solve the difficult problem of naming, it at least provides a solution. Suggestion, can solve it faster and avoid imagining things
  • cssrem A VSCode plug-in for converting CSS values ​​​​to REM

html The font I designed here is to use 14px, so when transferring, the corresponding relationship should be 1rem = 14px, so it needs to be configured in the user settings

// 第三方插件cssrem配置
  "cssrem.rootFontSize": 14
Copy after login
  • Vue Peek Right-click to open or preview the referenced component
  • filesize Calculate the source file size and display it in the lower left corner
  • GitLens git history viewing, submission record viewing, history comparison, version rollback, artifact Not parsing
  • Import Cost Calculate the file size introduced by import
  • IntelliSense for CSS class names in HTML class is based on the definition found in the workspace or Provides CSS class name completion for HTML attributes via external files referenced by the link element.

Because we use vue language to develop, we also need to configure css prompts for vue

"html-css-class-completion.includeGlobPattern": "**/*.{css,html,vue}"
Copy after login
  • Live Server Provides support for Real-time service preview of HTML, instant refresh of code changes

  • Path Intellisense Path introduction of intelligent sensing

  • npm -intellisense npm module introduces intelligent sensing

  • RegExp Preview and Editor Regular expression preview and editing

  • Settings Sync Synchronize your vscode settings, including plug-ins, themes and all user data

  • SVG Viewer Preview SVG

  • Todo Tree Display the TODO list in your code

  • ##translate Translate

  • Tslint ts code format detection tool

  • Version Lens npm version detection

  • vscode-fileheader Generate document comment header

  • JavaScript (ES6) code snippets es code snippets

  • Copy Relative Path Copy relative path

For more programming related knowledge, please visit:

Programming Video! !

The above is the detailed content of How to configure vue in VSCode and use Vetur language recognition engine!. For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Roblox: Bubble Gum Simulator Infinity - How To Get And Use Royal Keys
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Nordhold: Fusion System, Explained
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Mandragora: Whispers Of The Witch Tree - How To Unlock The Grappling Hook
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Hot Topics

Java Tutorial
1673
14
PHP Tutorial
1278
29
C# Tutorial
1257
24
What computer configuration is required for vscode What computer configuration is required for vscode Apr 15, 2025 pm 09:48 PM

VS Code system requirements: Operating system: Windows 10 and above, macOS 10.12 and above, Linux distribution processor: minimum 1.6 GHz, recommended 2.0 GHz and above memory: minimum 512 MB, recommended 4 GB and above storage space: minimum 250 MB, recommended 1 GB and above other requirements: stable network connection, Xorg/Wayland (Linux)

Netflix's Frontend: Examples and Applications of React (or Vue) Netflix's Frontend: Examples and Applications of React (or Vue) Apr 16, 2025 am 12:08 AM

Netflix uses React as its front-end framework. 1) React's componentized development model and strong ecosystem are the main reasons why Netflix chose it. 2) Through componentization, Netflix splits complex interfaces into manageable chunks such as video players, recommendation lists and user comments. 3) React's virtual DOM and component life cycle optimizes rendering efficiency and user interaction management.

How to solve the problem of vscode Chinese annotations becoming question marks How to solve the problem of vscode Chinese annotations becoming question marks Apr 15, 2025 pm 11:36 PM

How to solve the problem that Chinese comments in Visual Studio Code become question marks: Check the file encoding and make sure it is "UTF-8 without BOM". Change the font to a font that supports Chinese characters, such as "Song Style" or "Microsoft Yahei". Reinstall the font. Enable Unicode support. Upgrade VSCode, restart the computer, and recreate the source file.

vscode terminal usage tutorial vscode terminal usage tutorial Apr 15, 2025 pm 10:09 PM

vscode built-in terminal is a development tool that allows running commands and scripts within the editor to simplify the development process. How to use vscode terminal: Open the terminal with the shortcut key (Ctrl/Cmd). Enter a command or run the script. Use hotkeys (such as Ctrl L to clear the terminal). Change the working directory (such as the cd command). Advanced features include debug mode, automatic code snippet completion, and interactive command history.

Where to write code in vscode Where to write code in vscode Apr 15, 2025 pm 09:54 PM

Writing code in Visual Studio Code (VSCode) is simple and easy to use. Just install VSCode, create a project, select a language, create a file, write code, save and run it. The advantages of VSCode include cross-platform, free and open source, powerful features, rich extensions, and lightweight and fast.

vscode Previous Next Shortcut Key vscode Previous Next Shortcut Key Apr 15, 2025 pm 10:51 PM

VS Code One-step/Next step shortcut key usage: One-step (backward): Windows/Linux: Ctrl ←; macOS: Cmd ←Next step (forward): Windows/Linux: Ctrl →; macOS: Cmd →

Common commands for vscode terminal Common commands for vscode terminal Apr 15, 2025 pm 10:06 PM

Common commands for VS Code terminals include: Clear the terminal screen (clear), list the current directory file (ls), change the current working directory (cd), print the current working directory path (pwd), create a new directory (mkdir), delete empty directory (rmdir), create a new file (touch) delete a file or directory (rm), copy a file or directory (cp), move or rename a file or directory (mv) display file content (cat) view file content and scroll (less) view file content only scroll down (more) display the first few lines of the file (head)

vscode terminal command cannot be used vscode terminal command cannot be used Apr 15, 2025 pm 10:03 PM

Causes and solutions for the VS Code terminal commands not available: The necessary tools are not installed (Windows: WSL; macOS: Xcode command line tools) Path configuration is wrong (add executable files to PATH environment variables) Permission issues (run VS Code as administrator) Firewall or proxy restrictions (check settings, unrestrictions) Terminal settings are incorrect (enable use of external terminals) VS Code installation is corrupt (reinstall or update) Terminal configuration is incompatible (try different terminal types or commands) Specific environment variables are missing (set necessary environment variables)

See all articles