==日常編輯==
• 按住Ctrl滾滾輪,代碼的字體會隨你心意變大變小。
• 在編輯區按住右鍵可拖動代碼,省去拉(尤其是橫向)滾動條之麻煩;相關設置:Mouse Drag Scrolling。
• Ctrl+D可複製當前行或選中塊。
• Ctrl+Shift+C註釋掉當前行或選中塊,Ctrl+Shift+X則解除註釋。
• Tab縮進當前行或選中塊,Shift+Tab減少縮進。
• 可拖動選中塊使其移動到新位置,按住Ctrl則爲複製到新位置。
• 按下Atl,再拖動鼠標,可以實現部分選擇(即只選中一個區域內的字符,而不會包含它們所在行的其他字符)。
• 需要更大編輯空間時,F2和Shift+F2分別可以顯隱下方Logs & others欄和左方的Management欄。
==自動完成與縮寫==
1)優化代碼自動完成功能:在Code-completion and symbol browser中,
• 將Automatically launch when typed # letter中的4改成2,這樣打兩個字母就會有提示了。
• 將Keyword sets to additionally include中1到9都勾上(可在Syntax highlighting 的keywords...中設置,其中1是C++關鍵字,3是Doxygen關鍵字;我曾將wxWidgets的類名都加入7並設置相應的字體(粗黑 體),看代碼時特別爽)
• 將Delay for auto-kick-in when typing [.::->]拉到 200ms,這樣快點出來提示
• 選中Case-sensitive match,防止一些無關的東西干擾,如果你想它幫你糾正大小寫,那就去掉勾
• 在Keyboard short-cuts中將Edit->Code complete的快捷鍵由Ctrl+Space改爲Alt+/,因爲前者與中文輸入法切換衝突,該快捷鍵爲已經輸入的(不是正在輸入的)詞提供自動完成。
2)看Abbreviation一欄,裏面定義了許多縮寫(還可以自定義),只要輸入這些縮寫,並按Ctrl+J,就可以自動完成常用的代碼框架,並將光標放在恰當的地方(自定義時用|表達)。常用的有:guard、class、switch等。
3)如果你聲明瞭一個類,你可以在cpp文件中右擊,Insert->All class methods without implementation...來插入你還沒定義的方法的定義(省去不少打字的功夫哦),也可使用Insert->Class Method declaration/implementation...來插入一個方法的聲明或定義。
==導航相關==
• Ctrl+G 到達指定行,ALT+G 到達指定文件,Ctrl+Alt+G 到達指定函數(支持頭文件中的函數定義),F11 切換源文件與頭文件。
• Ctrl+PageUp 到達上一個函數,Ctrl+PageDown 到達下一個函數。
• Ctrl+B 添加書籤,Alt+PageUp和Alt+PageDown可以切換書籤。
• Ctrl+Shift+B可找到匹配的括號。
• 看長代碼時,可右擊,Folding->Fold All,然後慢慢展開來看,也可充分利用左方Management欄的Symbol瀏覽器。
• 在一個變量、函數或宏上右擊,三個以Find開頭的菜單項,分別可以爲你轉到它的聲明、定義和找到所有出現的地方(按F2在下方Thread Search那裏查看)。
其他:
• General Settings中可以設置縮進、自動換行等細節。
• 讓Code::Blocks永遠記住你的Layout,尤其是debug的layout,善用debug工具欄。
• 備份C:/Documents and Settings/[你的用戶名]/Application Data/codeblocks/Default.conf,如遇重裝,將其放在codeblocks.exe所在目錄,就不會丟失你的配置;這樣也可以 打造出Code::Blocks的綠色版。
Ctrl+L 剪切選中行
F11 切換源文件與頭文件
F10 全屏
Ctrl+Shift+B 括號匹配
按下ATL,再拖動鼠標,可以實現部分選擇
Ctrl+B 添加書籤,ALT+PageUp和PageDown可以切換書籤。
Ctrl+G 到達指定行
ALT+G 到達指定文件
Ctrl+Alt+G 到達指定函數(支持頭文件中的函數定義)
Ctrl+PageUp 到達上一個函數
Ctrl+PageDown 到達下一個函數
快捷鍵
Function Shortcut Key
Undo last action Ctrl + Z
Redo last action Ctrl + Shift +Z
Cut selected text Ctrl + X
Copy selected text Ctrl +C
Paste text from clipboard Ctrl +V
Select all text Ctrl + A
Swap header / source F11
Comment highlighted code Ctrl +Shift + C
Uncomment highlighted code Ctrl+ Shift + X
Duplicate line caret is on Ctrl+ D
Auto-complete /Abbreviations Ctrl + Space /Ctrl + J
Show call tip Ctrl + Shift +Space
Swap line caret is on with line aboveit Ctrl + T
Toggle bookmark Ctrl + B
Goto previous bookmark Alt +PgUp
Goto next bookmark Alt +PgDown
Toggle current blockfolding F12
Toggle all folds Shift +F12
CodeBlocks代碼編輯器組件提供的快捷鍵,這些快捷鍵不能重新綁定(rebound)。
Function Shortcut Key
Magnify text size. Ctrl + Keypad"+"
Reduce text size. Ctrl + Keypad"-"
Restore text size tonormal. Ctrl + Keypad "/"
Cycle through recent files. Ctrl+ Tab
Indent block. Tab
Dedent block. Shift + Tab
Delete to start of word. Ctrl +BackSpace
Delete to end of word. Ctrl +Delete
Delete to start of line. Ctrl +Shift + BackSpace
Delete to end of line. Ctrl +Shift + Delete
Go to start of document. Ctrl +Home
Extend selection to start ofdocument. Ctrl + Shift +Home
Go to start of display line. Alt+ Home
Extend selection to start of displayline. Alt + Shift + Home
Go to end of document. Ctrl +End
Extend selection to end ofdocument. Ctrl + Shift +End
Go to end of display line. Alt +End
Extend selection to end of displayline. Alt + Shift + End
Expand or contract a foldpoint. Ctrl + Keypad "*"
Create or delete abookmark. Ctrl + F2
Go to next bookmark. F2
Select to next bookmark. Alt +F2
Find selection. Ctrl + F3
Find selection backwards. Ctrl +Shift + F3
Scroll up. Ctrl + Up
Scroll down. Ctrl + Down
Line cut. Ctrl + L
Line copy. Ctrl + Shift +T
Line delete. Ctrl + Shift +L
Line transpose withprevious. Ctrl + T
Line duplicate. Ctrl + D
Find matching preprocessor conditional, skipping nestedones. Ctrl + K
Select to matching preprocessorconditional. Ctrl + Shift +K
Find matching preprocessor conditional backwards, skipping nestedones. Ctrl + J
Select to matching preprocessor conditionalbackwards. Ctrl + Shift +J
Previous paragraph. Shift extendsselection. Ctrl + [
Next paragraph. Shift extendsselection. Ctrl + ]
Previous word. Shift extendsselection. Ctrl + Left
Next word. Shift extendsselection. Ctrl + Right
Previous word part. Shift extendsselection. Ctrl + /
Next word part. Shift extendsselection. Ctrl + \
Files
Function Shortcut Key
New file or project Ctrl +N
Open existing file orproject Ctrl + O
Save current file Ctrl + S
Save all files Ctrl + Shift +S
Close current file Ctrl + F4 /Ctrl + W
Close all files Ctrl + Shift +F4 / Ctrl + Shift + W
CodeBlocks的Tab組件所提供的快捷鍵,這些快捷鍵不能重新綁定(rebound)。
Function Shortcut Key
Activate next open file Ctrl +Tab
Activate previous open file Ctrl+ Shift + Tab
View
Function Shortcut Key
Show / hide Messagespane F2
Show / hide Managementpane Shift + F2
Move project up (in Projecttree) Ctrl + Shift + Up
Move project down (in Projecttree) Ctrl + Shift + Down
Activate prior (in Projecttree) Alt + F5
Activate next (in Projecttree) Alt + F6
Zoom in / out Ctrl + Roll MouseWheel
Focus editor CTRL + Alt +E
Search
Function Shortcut Key
Find Ctrl + F
Find next F3
Find previous Shift + F3
Find in files Crtl + Shift +F
Replace Ctrl + R
Replace in files Ctrl + Shift +R
Goto line Ctrl + G
Goto next changed line Ctrl +F3
Goto previous changed line Ctrl+ Shift + F3
Goto file Alt + G
Goto function Ctrl + Alt +G
Goto previous function Ctrl +PgUp
Goto next function Ctrl +PgDn
Goto declaration Ctrl + Shift +.
Goto implementation Ctrl +.
Open include file Ctrl + Alt +.
Build
Function Shortcut Key
Build Ctrl + F9
Compile current file Ctrl +Shift + F9
Run Ctrl + F10
Build and Run F9
Rebuild Ctrl + F11
Debug
Function Shortcut Key
Debug F8
Continue debugging Ctrl +F7
Step over a code block F7
Step into a code block Shift +F7
Step out of a code block Ctrl +Shift + F7
Toggle breakpoint F5
Run to cursor F4
Previous error Alt + F1
Next error Alt + F2