跳至主要内容

[IDE] Jetbrain Goland 筆記

從 Terminal 中直接啟動 Goland

  1. 打開 Goland
  2. 點擊上方工具列中的 Tools -> Create Command-line Launcher

Launch IntelliJ IDEA or Goland from command line (Linux or MacOs)

存檔時自動執行 format tool

Running 'goimports' on save in GoLand @ StackOverflow

透過 Goland 中的 File Watchers 可以添加存檔時要執行的 format tool:

Imgur

快捷鍵

功能快捷鍵
Search EverywhereShift + Shift
執行程式(Run, Debugging Actions, Evaluate ExpressionAlt + F8
Replace in Path(搜尋並取代)Cmd + Shift + R
Fold Allcmd + shift + -
選取或移動程式碼Alt + Shift + 上下左右
擴展選取下上行的程式碼Alt + 上/下
註解程式碼cmd + /
觸發 Auto Completectrl + space
找出該 element 可以使用的 function(ctrl + space) * 2
重新命名變數/檔案(rename)shift + F6
將方法中的值獨立成變數(Extract Variable)cmd + alt + V
將變數放入方法中(Inline)cmd + alt + N
將程式拆成函式(Extract Function / Method)cmd + alt + M
Code Formattingcmd + alt + L
go fmtcmd + alt + shift + F
到程式錯誤提示的位置F2
依據建議修正錯誤alt + enter
執行程式ctrl + shift + R

游標與文字

功能快捷鍵
選取相同文字ctrl + G
產生多個游標按住 alt 點擊滑鼠
減少縮排shift + Tab

新增、移動、複製、刪除行

Add, Delete, and Move Lines

功能快捷鍵
複製一行cmd + D
刪除一行cmd + back space
選取或移動程式碼Alt + Shift + 上下左右

其他

不要讓 test 的檔案有高亮效果

Disable test file highlighting in Project explorer and Editor Tab

進到 Settings > Appearance & Behavior > File Colors,把 Tests 檔案的高亮取消。

檔案類型無法被正確辨識

keywords: file type, extension

One .js file not recognized as javascipt, others ok @ Jetbrains Support

這通常會發生在新增了一個沒有副檔名的檔案後,Jetbrain 會把它做了一個不適當的自動辨識。

到 Editor > File Types > 找到應該要被辨認成的副檔名,看看是不是該檔名被加入到分類中,如果是的話則將其移除。要檢查 File Types 中下述三個位置:

  • Auto-detect file type by content
  • 原本應該要被辨識成的檔案類型
  • Text

Auto-detect file type by content

原本應該要被辨識成的檔案類型