VSCode格式化js不换行(格式化js时候{}中内容不自动换行)

  1 {
  2   //设置文字大小
  3   "editor.fontSize": 18,
  4   //设置文字行高
  5   "editor.lineHeight": 24,
  6   //开启行数提示
  7   "editor.lineNumbers": "on",
  8   // 在输入时显示含有参数文档和类型信息的小面板。
  9   "editor.parameterHints.enabled": true,
 10   // 调整窗口的缩放级别
 11   "window.zoomLevel": 0,
 12   // 文件目录
 13   // "workbench.iconTheme": "vscode-icons",
 14   // 设置字体
 15   "editor.fontFamily": "'Droid Sans Mono', 'Courier New', monospace, 'Droid Sans Fallback'",
 16   // 自动换行
 17   "editor.wordWrap": "on",
 18   // 自定义vscode面板颜色
 19   "workbench.colorCustomizations": {
 20     // "tab.activeBackground": "#253046", // 活动选项卡的背景色
 21     // "activityBar.background": "#253046", //活动栏背景色
 22     // "sideBar.background": "#253046", //侧边栏背景色
 23     // "activityBar.foreground": "#23f8c8", //活动栏前景色(例如用于图标)
 24     "editor.background": "#292a2c" //编辑器背景颜色
 25   },
 26   // vscode默认启用了根据文件类型自动设置tabsize的选项
 27   "editor.detectIndentation": false,
 28   // 重新设定tabsize
 29   "editor.tabSize": 2,
 30   // #每次保存的时候自动格式化
 31   "editor.formatOnSave": true,
 32   //  #让函数(名)和后面的括号之间加个空格
 33   "javascript.format.insertSpaceBeforeFunctionParenthesis": false,
 34   // #这个按用户自身习惯选择
 35   "vetur.format.defaultFormatter.html": "js-beautify-html",
 36   // #让vue中的js按编辑器自带的ts格式进行格式化 
 37   "vetur.format.defaultFormatter.js": "vscode-typescript",
 38   // 保存时运行的代码ESLint操作类型。
 39   "editor.codeActionsOnSave": {
 40     "source.fixAll.eslint": true
 41   },
 42   // 添加emmet支持vue文件
 43   "emmet.includeLanguages": {
 44     "wxml": "html",
 45     "vue": "html"
 46   },
 47   // 两个选择器中是否换行
 48   "minapp-vscode.disableAutoConfig": true,
 49   //快速预览(右侧)
 50   "editor.minimap.enabled": true,
 51   // tab 代码补全
 52   "files.associations": {
 53     "*.wpy": "vue",
 54     "*.vue": "vue",
 55     "*.cjson": "jsonc",
 56     "*.wxss": "css",
 57     "*.wxs": "javascript"
 58   },
 59   // 用来配置如何使用ESLint CLI引擎API启动ESLint。 默认为空选项
 60   "eslint.options": {
 61     "extensions": [
 62       ".js",
 63       ".vue"
 64     ]
 65   },
 66   // 在onSave还是onType时执行linter。默认为onType。
 67   "eslint.run": "onSave",
 68   // 启用ESLint作为已验证文件的格式化程序。
 69   "eslint.format.enable": true,
 70   // 语言标识符的数组,为此ESLint扩展应被激活,并应尝试验证文件。
 71   "eslint.probe": [
 72     "javascript",
 73     "javascriptreact",
 74     "vue-html",
 75     "vue",
 76     "html"
 77   ],
 78   //关闭rg.exe进程 用cnpm导致会出现rg.exe占用内存很高
 79   "search.followSymlinks": false,
 80   // 给js-beautify-html设置属性隔断
 81   "vetur.format.defaultFormatterOptions": {
 82     "js-beautify-html": {
 83       "wrap_attributes": "aligned-multiple",
 84       "wrap_line_length": 500,
 85       "end_with_newline": false
 86     },
 87     "prettyhtml": {
 88       "printWidth": 500,
 89       "singleQuote": false,
 90       "wrapAttributes": false,
 91       "sortAttributes": false
 92     },
 93     "prettier": {
 94       "semi": false,
 95       "singleQuote": true
 96     }
 97   },
 98   // style默认偏移一个indent
 99   "vetur.format.styleInitialIndent": true,
100   // 定义匿名函数的函数关键字后面的空格处理。
101   "javascript.format.insertSpaceAfterFunctionKeywordForAnonymousFunctions": true,
102   // 定义函数参数括号前的空格处理方式。
103   "typescript.format.insertSpaceBeforeFunctionParenthesis": true,
104   // 新版本消息
105   "vsicons.dontShowNewVersionMessage": true,
106   // 控制资源管理器是否在把文件删除到废纸篓时进行确认。
107   "explorer.confirmDelete": false,
108   // 使用eslint-plugin-vue验证<template>中的vue-html
109   "vetur.validation.template": false,
110   // 格式化js时候{}中内容不自动换行
111   "beautify.config": {
112     "brace_style": "collapse,preserve-inline"
113   },
114   "beautify.language": {
115     "js": {
116       "type": [
117         "javascript",
118         "json",
119         "jsonc"
120       ],
121       "filename": [
122         ".jshintrc",
123         ".jsbeautifyrc"
124       ]
125     },
126     "css": [
127       "css",
128       "less",
129       "scss"
130     ],
131     "html": [
132       "htm",
133       "html"
134     ]
135   },
136   "terminal.integrated.confirmOnExit": true,
137   "terminal.integrated.copyOnSelection": true,
138   "terminal.integrated.cursorBlinking": true,
139   "json.trace.server": "messages",
140   "sshfs.configpaths": [],161   "javascript.format.placeOpenBraceOnNewLineForFunctions": true,
162   "javascript.implicitProjectConfig.checkJs": true,
163   "javascript.implicitProjectConfig.experimentalDecorators": true,165   "editor.formatOnPaste": true,
166   "editor.formatOnType": true,
167   // 指定用在工作台中的颜色主题。
168   // "workbench.colorTheme": "One Dark Pro"
169 }
{
  //设置文字大小
  "editor.fontSize"18,
  //设置文字行高
  "editor.lineHeight"24,
  //开启行数提示
  "editor.lineNumbers""on",
  // 在输入时显示含有参数文档和类型信息的小面板。
  "editor.parameterHints.enabled"true,
  // 调整窗口的缩放级别
  "window.zoomLevel"0,
  // 文件目录
  // "workbench.iconTheme": "vscode-icons",
  // 设置字体
  "editor.fontFamily""'Droid Sans Mono', 'Courier New', monospace, 'Droid Sans Fallback'",
  // 自动换行
  "editor.wordWrap""on",
  // 自定义vscode面板颜色
  "workbench.colorCustomizations": {
    // "tab.activeBackground": "#253046", // 活动选项卡的背景色
    // "activityBar.background": "#253046", //活动栏背景色
    // "sideBar.background": "#253046", //侧边栏背景色
    // "activityBar.foreground": "#23f8c8", //活动栏前景色(例如用于图标)
    "editor.background""#292a2c" //编辑器背景颜色
  },
  // vscode默认启用了根据文件类型自动设置tabsize的选项
  "editor.detectIndentation"false,
  // 重新设定tabsize
  "editor.tabSize"2,
  // #每次保存的时候自动格式化
  "editor.formatOnSave"true,
  //  #让函数(名)和后面的括号之间加个空格
  "javascript.format.insertSpaceBeforeFunctionParenthesis"false,
  // #这个按用户自身习惯选择
  "vetur.format.defaultFormatter.html""js-beautify-html",
  // #让vue中的js按编辑器自带的ts格式进行格式化 
  "vetur.format.defaultFormatter.js""vscode-typescript",
  // 保存时运行的代码ESLint操作类型。
  "editor.codeActionsOnSave": {
    "source.fixAll.eslint"true
  },
  // 添加emmet支持vue文件
  "emmet.includeLanguages": {
    "wxml""html",
    "vue""html"
  },
  // 两个选择器中是否换行
  "minapp-vscode.disableAutoConfig"true,
  //快速预览(右侧)
  "editor.minimap.enabled"true,
  // tab 代码补全
  "files.associations": {
    "*.wpy""vue",
    "*.vue""vue",
    "*.cjson""jsonc",
    "*.wxss""css",
    "*.wxs""javascript"
  },
  // 用来配置如何使用ESLint CLI引擎API启动ESLint。 默认为空选项
  "eslint.options": {
    "extensions": [
      ".js",
      ".vue"
    ]
  },
  // 在onSave还是onType时执行linter。默认为onType。
  "eslint.run""onSave",
  // 启用ESLint作为已验证文件的格式化程序。
  "eslint.format.enable"true,
  // 语言标识符的数组,为此ESLint扩展应被激活,并应尝试验证文件。
  "eslint.probe": [
    "javascript",
    "javascriptreact",
    "vue-html",
    "vue",
    "html"
  ],
  //关闭rg.exe进程 用cnpm导致会出现rg.exe占用内存很高
  "search.followSymlinks"false,
  // 给js-beautify-html设置属性隔断
  "vetur.format.defaultFormatterOptions": {
    "js-beautify-html": {
      "wrap_attributes""aligned-multiple",
      "wrap_line_length"500,
      "end_with_newline"false
    },
    "prettyhtml": {
      "printWidth"500,
      "singleQuote"false,
      "wrapAttributes"false,
      "sortAttributes"false
    },
    "prettier": {
      "semi"false,
      "singleQuote"true
    }
  },
  // style默认偏移一个indent
  "vetur.format.styleInitialIndent"true,
  // 定义匿名函数的函数关键字后面的空格处理。
  "javascript.format.insertSpaceAfterFunctionKeywordForAnonymousFunctions"true,
  // 定义函数参数括号前的空格处理方式。
  "typescript.format.insertSpaceBeforeFunctionParenthesis"true,
  // 新版本消息
  "vsicons.dontShowNewVersionMessage"true,
  // 控制资源管理器是否在把文件删除到废纸篓时进行确认。
  "explorer.confirmDelete"false,
  // 使用eslint-plugin-vue验证<template>中的vue-html
  "vetur.validation.template"false,
  // 格式化js时候{}中内容不自动换行
  "beautify.config": {
    "brace_style""collapse,preserve-inline"
  },
  "beautify.language": {
    "js": {
      "type": [
        "javascript",
        "json",
        "jsonc"
      ],
      "filename": [
        ".jshintrc",
        ".jsbeautifyrc"
      ]
    },
    "css": [
      "css",
      "less",
      "scss"
    ],
    "html": [
      "htm",
      "html"
    ]
  },
  "terminal.integrated.confirmOnExit"true,
  "terminal.integrated.copyOnSelection"true,
  "terminal.integrated.cursorBlinking"true,
  "json.trace.server""messages",
  "sshfs.configpaths": [],
  "sshfs.configs": [
    {
      "agent""//./pipe/openssh-ssh-agent",
      "host""192.9.200.247",
      "name""192.9.200.247",
      "password""gjj_v4pe",
      "port"22,
      "root""/tmp",
      "username""administrator"
    },
    {
      "agent""//./pipe/openssh-ssh-agent",
      "host""192.9.200.222",
      "name""192.9.200.222",
      "password""lingroot",
      "port"22,
      "root""/home",
      "username""root"
    }
  ],
  "javascript.format.placeOpenBraceOnNewLineForFunctions"true,
  "javascript.implicitProjectConfig.checkJs"true,
  "javascript.implicitProjectConfig.experimentalDecorators"true,
  "terminal.integrated.shell.windows""C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe",
  "editor.formatOnPaste"true,
  "editor.formatOnType"true,
  // 指定用在工作台中的颜色主题。
  // "workbench.colorTheme": "One Dark Pro"
}
用自己所知道的去帮助他人,就像别人当初帮助自己一样!
原文地址:https://www.cnblogs.com/ywf520/p/15107241.html