How do you change the formatting options in Visual Studio Code?

后端 未结 8 1491
后悔当初
后悔当初 2020-12-07 19:37

I know you can Format Code using Ctrl+F / Cmd+F in Visual Studio Code but how do you change the formatting options for each langu

8条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-07 20:16

    A solution that works for me (July 2017), is to utilize ESLint. As everybody knows, you can use the linter in multiple ways, globally or locally. I use it locally and with the google style guide. They way I set it up is as follow...

    • cd to your working directory
    • npm init
    • npm install --save-dev eslint
    • node_modules/.bin/eslint --init
    • I use google style and json config file

    Now you will have a .eslintrc.json file the root of your working directory. You can open that file and modify as you please utilizing the eslint rules. Next cmd+, to open vscode system preferences. In the search bar type eslint and look for "eslint.autoFixOnSave": false. Copy the setting and pasted in the user settings file and change false to true. Hope this can help someone utilizing vscode.

提交回复
热议问题