VSCode 格式化縮排程式碼的實現
阿新 • • 發佈:2020-08-07
1)檔案 —> 首選項
因為 VsCode 預設啟用了根據檔案型別自動設定tabsize的選項,在設定中新增:
"editor.detectIndentation": false
2)編輯器配置
在專案檔案中新建 .editorconfig
檔案
為特定型別檔案指定縮排大小、縮排型別(空格,或tab),是否自動插入末行等等。
root = true [*] charset = utf-8 indent_style = tab indent_size = 4 insert_final_newline = true trim_trailing_whitespace = true [*.md] max_line_length = off trim_trailing_whitespace = false
3)安裝 VsCode 格式化程式碼外掛
搜尋並安裝 Beautify 格式化程式碼外掛
使用指南:
開啟要格式化的檔案 —> F1 —> Beautify file —> 選擇你要格式化的程式碼型別
4)格式化對齊快捷鍵:
- Windows: Ctrl + K + F
- Windows:Shift + Alt + F
- Mac: Shift + Option + F
- Ubuntu: Ctrl + Shift + I
到此這篇關於VSCode 格式化縮排程式碼的實現的文章就介紹到這了,更多相關VSCode 格式化縮排內容請搜尋我們以前的文章或繼續瀏覽下面的相關文章希望大家以後多多支援我們!