花一天的篇幅來提及Webstorm IDE的程式碼風格 與 快捷熱鍵
帶大家避開一些 團隊合作時程式碼風格不同 的坑
以及開發常用熱鍵,掌握這些技巧可以大幅提升開發速度
Editor > Font
或直接搜尋font

如果macOS要更換成zsh的話
Tools > Terminal > Application Settings
或直接搜尋terminal

Editor > Color Scheme > Console Font
或直接搜尋console font

Editor > General > Console
或直接搜尋commands history size

Typescript 與 Javascript區塊的設定介面非常相像
可參照以下的設定方式,自行再調整Javascript介面設定
Editor > Code Style > Typescript > Spaces

Object literal braces物件旁大括號
ES6 import/export bracesimport 時大括號
Editor > Code Style > Typescript > Wrapping and Braces > ES6 import/export預設為
Chop down if long
建議調成Do not wrap

Do not wrap: 不換行
Wrap if long: 太長再換
Chop down if long: 能換盡量換
Wrap always: 遇到逗號要換
Editor > Code Style > Typescript > Punctuation
或直接搜尋single quote

single always總是使用單引號/雙引號
double in new code新代碼使用單引號/雙引號
Editor > Code Style > Typescript > Wrapping and Braces
或直接搜尋Align when multiline

Function declaration parameters函式參數對齊
Function declaration arguments函式引數對齊
Chained method calls連鎖方法呼叫對齊
for() statementfor迴圈敘述對齊
Editor > Code Style > HTML > Code Generation

Line comment at first column行註解位置從第一欄開始
Block comment at first column區塊註解位置從第一欄開始
Add spaces around block comments註解內兩側留白
Webstorm預設會在儲存時將檔案尾行留一行空白
Editor > General >Ensure every saved file ends with a line break
或直接搜尋end with line break

Editor > Code Style > General > Hard wrap at
或直接搜尋Hard wrap可調整當超出幾個字元時自動換行

這邊調整是全域的
可個別再到HTML、Javascript、Typescript底下針對語言調整
可將檔案或資料夾排出搜尋(ex: 尋找宣告或引用、程式碼搜尋)
右鍵 > Mark Directory as > Excluded
若不慎動到重要設定無法復原,可刪除專案內
.idea資料夾來回到預設
以下快捷鍵以 Windows 為主
macOS 把文章中的Ctrl更換為Command即可
Ctrl + ZCtrl + Shift + Z
Undo、Redo有次數限制 (且無法自訂次數)
加上會占用龐大記憶體(Memory)於是Webstorm有個替代方案是
Local History,記錄檔案的各種異動透過
Shift + Shift搜尋Local History可將檔案恢復成以前的樣子
local history是儲存在硬碟(Disk)中
可透過搜尋local history修改歷史保留天數
Ctrl + SIDE會偵測變更自動儲存,但並非隨時隨地
有時候會過一下才儲存、或者遇到卡住的情況
可以手動儲存,立即儲存變更來加快速度
Ctrl + FCtrl + /Ctrl + Shift + /輸入法要切成
Eng模式中文輸入法只能按數字鍵區塊的
/
Ctrl + 左鍵、Ctrl + B導到宣告或引用的地方按
Ctrl + 左鍵
或者讓光標停留在關鍵字上按Ctrl + B
ctrl + alt + ←ctrl + alt + →Shift + Shift搜尋任意檔案名稱
Ctrl + E選擇要開啟哪個檔案
alt + F1按
1Project View
Ctrl + Shift + F
可使用 File mask 依照檔案名稱來限制搜索範圍
- 問號
?代表 1個 任意字元- 星號
*代表 0~多個 任意字元ex:
*.html、store*、sto??.component.html
皆可以搜尋的到store.component.html檔案
Ctrl + Shift + RCtrl + Alt + L