shift+alt+f 全部格式化 ctrl+k f 选定格式化 在这里插入图片描述 格式化后: 在这里插入图片描述 Visual Studio 2019 C++反正是分号后自动格式化,相当实用,那么VSCODE是由可以实现相同的功能?当然可以!JSON设置一下即可。 editor.formateOnType editor.formateOnSave editor.formateOnPaste。
九、代码折叠
每个代码有对应的自动折叠语法,如C++的while for循环,点击VSCODE行数右边的以下符号符号。在这里插入图片描述 即可完成收起和展开,另外你也可以逐级收起,快捷键是shift+click不过这个也被占用了,需要解决一下冲突。如果对于一些你想折叠但是语言没有自动折叠怎么办?OK!实用语言对应标记,标记起始和终止区域。 Language Start region End region Bat ::#region or REM #region ::#endregion or REM #endregion C# #region #endregion C/C++ #pragma region #pragma endregion CSS/Less/SCSS /#region/ /#endregion/ Coffeescript #region #endregion F# //#region or (#_region) //#endregion or (#_endregion) Java //#region or // // #endregion or // Markdown Perl5 #region or =pod #endregion or =cut PHP #region #endregion PowerShell #region #endregion Python #region or # region #endregion or # endregion TypeScript/JavaScript //#region //#endregion Visual Basic #Region #End Region
像是这样: 在这里插入图片描述 这里是快捷键:
Fold (Ctrl+Shift+[) folds the innermost uncollapsed region at the cursor. Unfold (Ctrl+Shift+]) unfolds the collapsed region at the cursor. Toggle Fold (Ctrl+K Ctrl+L) folds or unfolds the region at the cursor. Fold Recursively (Ctrl+K Ctrl+[) folds the innermost uncollapsed region at the cursor and all regions inside that region. Unfold Recursively (Ctrl+K Ctrl+]) unfolds the region at the cursor and all regions inside that region. Fold All (Ctrl+K Ctrl+0) folds all regions in the editor. Unfold All (Ctrl+K Ctrl+J) unfolds all regions in the editor. Fold Level X (Ctrl+K Ctrl+2 for level 2) folds all regions of level X, except the region at the current cursor position. Fold All Block Comments (Ctrl+K Ctrl+/) folds all regions that start with a block comment token. Fold Marker Regions (Ctrl+K Ctrl+8) folds all marker regions. Unfold Marker Regions (Ctrl+K Ctrl+9) unfolds all marker regions