Indentation in VS Code

∥☆過路亽.° 提交于 2019-12-03 10:11:54

A couple things:

To format (make "pretty") all the code in a given file you can use Shift + Alt + F on Windows. See this answer for more information.

To adjust the user settings for tab size or to insert tabs as spaces, etc. you can edit settings.json (Ctrl + Shift + P then type "user settings"). You can then manually add/edit:

// number of spaces for a tab
"editor.tabSize": 2,

// insert spaces when pressing tab
"editor.insertSpaces": true

I believe both of these settings are overriden by "editor.detectIndentation" so you may have to look at that too.

Look at that to avoid content duplication
- https://stackoverflow.com/a/46856413/7668448
- https://stackoverflow.com/a/46855721/7668448

Also think about setting

  • "editor.formatOnPaste"
  • "editor.formatOnType"
  • "editor.formatOnSave"

to true, they default to false.

That of course by going to user settings (file>preference>settings or through pallet Ctrl+shift+P and write setting you will find within the choices).

Also it's a good thing to do the following: in default settings, in search settings bar, you write "format", then scroll and go through all the parameters related to formatting, it's a long list, but there is a lot of cool things.

What I do to indent everything properly is put {} brackets around everything or just remove and put the final } around the code, this seems to properly indent all of it, this said I mostly use c# I don't know if this works in other languages

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!