当前位置:网站首页>VS Code 格式化后 自动让函数名后有空格
VS Code 格式化后 自动让函数名后有空格
2022-07-26 16:53:00 【知识的搬运工旺仔】
VS Code 格式化后 自动让函数名后有空格
1. 简介
嗨,大家好!今天给大家分享一下,怎么在vscode中给函数名后边加空格,让函数名和()之间有空格,这里大家要注意的是:Prettier - Code formatter并不能实现这个功能,我们需要借助Vetur来实现,以前小编一直很迷,为什么配置都配置了。我们还是没有效果,其实是用错插件了,我们应该用Vetur.
2. setting.json配置代码
注意:这里只是一些代码片段,这里需要先安装Vetur这个插件,之后再配置。
// 这里是实现函数名后边有空格的效果
"vetur.format.defaultFormatter.js": "vscode-typescript",
"javascript.format.insertSpaceBeforeFunctionParenthesis": true,
3. setting.json 全部的配置
这里只是一些简单的位置,有一个Path Autocomplete 这个插件,这个也蛮好用的,如果有喜欢的可以配置一下,相应的配置在第二个注释的地方
{
// 基础配置
"editor.fontSize": 18,
"editor.detectIndentation": false,
"editor.tabSize": 2,
"window.zoomLevel": 2,
/* 路径自动提示配置 + PathA... */
"path-autocomplete.extensionOnImport": true,
"path-autocomplete.pathMappings": {
"@": "${folder}/src"
},
// 使用vscode-icons主题
"workbench.iconTheme": "vscode-icons",
// 每次保存的时候将代码按格式进行修复
"editor.formatOnSave": true,
"editor.codeActionsOnSave": {
"source.fixAll": true
},
"eslint.validate": ["javascript", "javascriptreact", "vue"],
"[javascript]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
// "editor.defaultFormatter": "vscode.typescript-language-features"
},
"[vue]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
// "editor.defaultFormatter": "rvest.vs-code-prettier-eslint"
},
"[jsonc]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[html]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[css]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
//vetur 格式化代码
// "vetur.format.defaultFormatter.js": "prettier",
// 这里是实现函数名后边有空格的效果
"vetur.format.defaultFormatter.js": "vscode-typescript",
"javascript.format.insertSpaceBeforeFunctionParenthesis": true,
"vetur.format.defaultFormatter.html": "prettyhtml",
"vetur.completion.autoImport": true,
"vetur.format.defaultFormatterOptions": {
"prettier": {
// 结尾无分号
"semi": false,
// 超过140个字符换行
"printWidth": 300,
// 使用单引号
"singleQuote": true,
// 无尾随逗号
"trailingComma": "none",
// 箭头函数单个参数不加分号
"arrowParens": "avoid"
},
"prettyhtml": {
"printWidth": 300
}
},
// 同上prettier格式化代码
"prettier.semi": false,
"prettier.printWidth": 300,
"prettier.tabWidth": 2,
"prettier.trailingComma": "none",
"prettier.singleQuote": true,
"prettier.arrowParens": "avoid",
"prettier.eslintIntegration": true,
"files.associations": {
"*.cjson": "jsonc",
"*.wxss": "css",
"*.wxs": "javascript"
},
// 指定wxml的格式化
"minapp-vscode.wxmlFormatter": "prettyHtml",
"minapp-vscode.disableAutoConfig": true,
"workbench.sideBar.location": "right",
"editor.formatOnType": true
}
4. 总结
其实,建议大家在配置 setting.json 的时候,配置自己需要的和知道的,要不然,配置很多,你也不知道怎么控制,出现什么问题,也是很郁闷的,就无从下手了。
边栏推荐
- [virtual machine data recovery] data recovery cases in which XenServer virtual machine is unavailable due to accidental power failure and virtual disk files are lost
- In depth exploration of ribbon load balancing
- Tupu 3D visual national style design | collision between technology and culture "cool" spark“
- Good afternoon, everyone. Please ask a question: how to start a job submitted in SQL from the savepoint? Problem Description: using SQL in Cl
- Machine learning - what are machine learning, supervised learning, and unsupervised learning
- Is it safe for Huishang futures to open an account online? What is the account opening process?
- 2022 年有哪些流行的技术?
- On the growth of data technicians
- Implement softmax classification from zero sum using mxnet
- Advantages of time series database and traditional database
猜你喜欢

Execution process of select statement in MySQL

Comparison between agile development and Devops

Definition of graph traversal and depth first search and breadth first search (I)

CCS tm4c123 new project

Spark统一内存划分

解决哈希冲突的几种方式

Pay attention to the traffic safety warning of tourism passenger transport issued by the Ministry of public security

In May, 2022, video user insight: user use time increased, and the platform achieved initial results in cost reduction and efficiency increase

国际大咖 VS 本土开源新星 | ApacheCon Asia 主题演讲议程全览

Ascend目标检测与识别-定制自己的AI应用
随机推荐
Summer Challenge openharmony greedy snake based on JS
天翼云Web应用防火墙(边缘云版)支持检测和拦截Apache Spark shell命令注入漏洞
来吧开发者!不只为了 20 万奖金,试试用最好的“积木”来一场头脑风暴吧!...
hosts该文件已设置为只读的解决方法
A collection of commonly used shortcut keys for office software
2022 年有哪些流行的技术?
图扑 3D 可视化国风设计 | 科技与文化碰撞炫酷”火花“
URL跳转漏洞
Ascend target detection and recognition - customize your own AI application
The first self-developed embedded 40nm industrial scale memory chip in China was released, breaking the status quo that the localization rate is zero
Common super easy to use regular expressions!
Is the rolling update of pod similar to Canary deployment or blue-green deployment?
Centos安装docker以及mysql和redis环境
JS 闭包 模拟私有变量 面试题 立即执行函数IIFE
About the adjustment of the game background, reading this article is enough
On the growth of data technicians
What are the popular technologies in 2022?
Just this time! Talk about the technical solutions of distributed system in detail
E-week finance | postal Huiwanjia bank opened; Wechat public call to stop four types of financial marketing publicity
解决哈希冲突的几种方式