vscode 使用
大约 10 分钟
vscode 使用
开发前设置
关闭保持自动格式化,并且设置缩进4个空格
1. 关闭保存自动格式化

2. 设置缩进4个空格
打开 设置 搜索detectindentation

如果没生 参考:https://www.jianshu.com/p/90171778459c
VSCode左下角的设置图标-->设置--> 输入框中搜索settings,随便点一个

/* prettier的配置 */
"prettier.printWidth": 100, // 超过最大值换行
"prettier.tabWidth": 4, // 缩进字节数
"prettier.useTabs": false, // 缩进不使用tab,使用空格
"prettier.semi": true, // 句尾添加分号
"prettier.singleQuote": true, // 使用单引号代替双引号
"prettier.proseWrap": "preserve", // 默认值。因为使用了一些折行敏感型的渲染器(如GitHub comment)而按照markdown文本样式进行折行
"prettier.arrowParens": "avoid", // (x) => {} 箭头函数参数只有一个时是否要有小括号。avoid:省略括号
"prettier.bracketSpacing": true, // 在对象,数组括号与文字之间加空格 "{ foo: bar }"
"prettier.disableLanguages": ["vue"], // 不格式化vue文件,vue文件的格式化单独设置
"prettier.endOfLine": "auto", // 结尾是 \n \r \n\r auto
"prettier.eslintIntegration": false, //不让prettier使用eslint的代码格式进行校验
"prettier.htmlWhitespaceSensitivity": "ignore",
"prettier.ignorePath": ".prettierignore", // 不使用prettier格式化的文件填写在项目的.prettierignore文件中
"prettier.jsxBracketSameLine": false, // 在jsx中把'>' 是否单独放一行
"prettier.jsxSingleQuote": false, // 在jsx中使用单引号代替双引号
"prettier.parser": "babylon", // 格式化的解析器,默认是babylon
"prettier.requireConfig": false, // Require a 'prettierconfig' to format prettier
"prettier.stylelintIntegration": false, //不让prettier使用stylelint的代码格式进行校验
"prettier.trailingComma": "es5", // 在对象或数组最后一个元素后面是否加逗号(在ES5中加尾逗号)
"prettier.tslintIntegration": false,
"terminal.integrated.allowMnemonics": true,
"terminal.integrated.automationShell.linux": "" // 不让prettier使用tslint的代码格式进行校验
///报错的话,检查一下有没有用逗号与上一项设置分隔
VScode格式化代码换行问题
VSCode左下角的设置图标-->设置--> 输入框中搜索settings,随便点一个
// 添加的内容
"vetur.format.defaultFormatterOptions": {
"js-beautify-html": {
"wrap_line_length": 120,
"wrap_attributes": "auto",//代码换行模式 auto force force-aligned force-expand-multiline
"end_with_newline": false
}
},
如果使用了 prettier 则

vscode 在此系统上禁止运行脚本
1、关闭 vscode
2、使用管理员身份打开vscode
3、在终端中执行 set-ExecutionPolicy RemoteSigned;
4、关闭用管理员身分打开的vscode,重新普通登录用户打开vscode就可以了
vscode 开发必要的插件
- Vetur:vue 代码提示
- open in browser :允许您在默认浏览器中打开当前文件
- Live Server : 启动具有实时重新加载功能的开发本地服务器
- Auto Close Tag : 自动添加 HTML/XML 关闭标记
- Auto Rename Tag : 自动重命名成对的 HTML/XML 标记
- Chinese (Simplified) Language Pack for Visual Studio Code : 此中文(简体)语言包为VS Code提供本地化界面
- ESLint: 前端检查
- HTML CSS Support : 用于 HTML 的 CSS 智能感知
- HTML Snippets : 完整的 HTML 标签
- JavaScript (ES6) code snippets :ES6 语法中的 JavaScript 代码片段——语法提示
- eclipse
快捷键设置
ctrl+shft+p 打开命令面板 输入 keyboard
配置文件的位置:C:\Users\lishihuan\AppData\Roaming\Code\User
格式化 ctrl+shift+f 失效,大概率是和输入法冲突(搜狗、微软输入法)
配置--没测试过
C:\Users\lishihuan\AppData\Roaming\Code\User\settings.json
{
"files.associations": {
"*.vue": "vue",
"*.wpy": "vue",
"*.wxml": "html",
"*.wxss": "css"
},
"terminal.integrated.shell.windows": "C:\\Windows\\System32\\cmd.exe",
"git.enableSmartCommit": true,
"git.autofetch": true,
"emmet.triggerExpansionOnTab": true,
"emmet.showAbbreviationSuggestions": true,
"emmet.showExpandedAbbreviation": "always",
"emmet.includeLanguages": {
"vue-html": "html",
"vue": "html",
"wpy": "html"
},
//主题颜色
//"workbench.colorTheme": "Monokai",
"git.confirmSync": false,
"explorer.confirmDelete": false,
"editor.fontSize": 14,
"window.zoomLevel": 1,
"editor.wordWrap": "on",
"editor.detectIndentation": false,
// 重新设定tabsize
"editor.tabSize": 2,
//失去焦点后自动保存
"files.autoSave": "onFocusChange",
// #值设置为true时,每次保存的时候自动格式化;
"editor.formatOnSave": false,
//每120行就显示一条线
"editor.rulers": [
],
// 在使用搜索功能时,将这些文件夹/文件排除在外
"search.exclude": {
"**/node_modules": true,
"**/bower_components": true,
"**/target": true,
"**/logs": true,
},
// 这些文件将不会显示在工作空间中
"files.exclude": {
"**/.git": true,
"**/.svn": true,
"**/.hg": true,
"**/CVS": true,
"**/.DS_Store": true,
"**/*.js": {
"when": "$(basename).ts" //ts编译后生成的js文件将不会显示在工作空中
},
"**/node_modules": true
},
// #让vue中的js按"prettier"格式进行格式化
"vetur.format.defaultFormatter.html": "js-beautify-html",
"vetur.format.defaultFormatter.js": "prettier",
"vetur.format.defaultFormatterOptions": {
"js-beautify-html": {
// #vue组件中html代码格式化样式
"wrap_attributes": "force-aligned", //也可以设置为“auto”,效果会不一样
"wrap_line_length": 200,
"end_with_newline": false,
"semi": false,
"singleQuote": true
},
"prettier": {
"semi": false,
"singleQuote": true
}
}
}