Implementation of vscode format indentation code


1) File > Preferences

Because vscode has enabled the option of automatically setting tabsize according to the file type by default, add:

"editor.detectIndentation": false


2) Editor configuration

New in project file.editorconfigfile
Specify the indent size, indent type (space, or tab), whether to automatically insert the last line, and so on for a specific type of file.

root = true

charset = utf-8
indent_style = tab
indent_size = 4
insert_final_newline = true
trim_trailing_whitespace = true

max_line_length = off
trim_trailing_whitespace = false

3) Install the vscode format code plug-in

Search for and install the beautify formatting code plug-in


Use guide:

Open the file to be formatted > F1 > beautify File > select the code type you want to format


4) Format alignment shortcut key:

  • Windows: Ctrl + K + F
  • Windows:Shift + Alt + F
  • Mac: Shift + Option + F
  • Ubuntu: Ctrl + Shift + I

This article on the implementation of vscode formatting indentation code to introduce this, more related vscode formatting indentation content, please search the previous articles of developeppaer or continue to browse the related articles below, I hope you will support developeppaer more in the future!