官方快捷鍵大全:https://code.visualstudio.com/docs/customization/keybindings
Visual Studio Code是個牛逼的編輯器,啟動非常快,完全可以用來代替其他文本文件編輯工具。又可以用來做開發,支持各種語言,相比其他IDE,輕量級完全可配置還集成Git感覺非常的適合前端開發。 所以我仔細研究了一下文檔未來可能會作為主力工具使用。
主命令框
最重要的功能就是F1
或Ctrl+Shift+P
打開的命令面板了,在這個命令框里可以執行VSCode的任何一條命令,甚至關閉這個編輯器。
按一下Backspace
會進入到Ctrl+P
模式里
在Ctrl+P
下輸入>
又可以回到Ctrl+Shift+P
模式。
在Ctrl+P
窗口下還可以
- 直接輸入文件名,跳轉到文件
?
列出當前可執行的動作!
顯示Errors或Warnings,也可以`Ctrl+Shift+M:
跳轉到行數,也可以Ctrl+G
直接進入@
跳轉到symbol(搜索變量或者函數),也可以Ctrl+Shift+O
直接進入@:
根據分類跳轉symbol,查找屬性或函數,也可以Ctrl+Shift+O
后輸入:
進入#
根據名字查找symbol,也可以Ctrl+T
常用快捷鍵
編輯器與窗口管理
同時打開多個窗口(查看多個項目)
- 打開一個新窗口:
Ctrl+Shift+N
- 關閉窗口:
Ctrl+Shift+W
同時打開多個編輯器(查看多個文件)
- 新建文件
Ctrl+N
- 文件之間切換
Ctrl+Tab
- 切出一個新的編輯器(最多3個)
Ctrl+\
,也可以按住Ctrl鼠標點擊Explorer里的文件名 - 左中右3個編輯器的快捷鍵
Ctrl+1
Ctrl+2
Ctrl+3
- 3個編輯器之間循環切換 Ctrl+`
- 編輯器換位置,
Ctrl+k
然后按Left
或Right
代碼編輯
格式調整
- 代碼行縮進
Ctrl+[
Ctrl+]
Ctrl+C
Ctrl+V
如果不選中,默認復制或剪切一整行- 代碼格式化:
Shift+Alt+F
,或Ctrl+Shift+P
后輸入format code
- 上下移動一行:
Alt+Up
或Alt+Down
- 向上向下復制一行:
Shift+Alt+Up
或Shift+Alt+Down
- 在當前行下邊插入一行
Ctrl+Enter
- 在當前行上方插入一行
Ctrl+Shift+Enter
光標相關
- 移動到行首:
Home
- 移動到行尾:
End
- 移動到文件結尾:
Ctrl+End
- 移動到文件開頭:
Ctrl+Home
- 移動到定義處:
F12
- 定義處縮略圖:只看一眼而不跳轉過去
Alt+F12
- 移動到后半個括號
Ctrl+Shift+]
- 選擇從光標到行尾
Shift+End
- 選擇從行首到光標處
Shift+Home
- 刪除光標右側的所有字
Ctrl+Delete
- Shrink/expand selection:
Shift+Alt+Left
和Shift+Alt+Right
- Multi-Cursor:可以連續選擇多處,然后一起修改,
Alt+Click
添加cursor或者Ctrl+Alt+Down
或Ctrl+Alt+Up
- 同時選中所有匹配的
Ctrl+Shift+L
Ctrl+D
下一個匹配的也被選中(被我自定義成刪除當前行了,見下邊Ctrl+Shift+K
)- 回退上一個光標操作
Ctrl+U
重構代碼
- 找到所有的引用:
Shift+F12
- 同時修改本文件中所有匹配的:
Ctrl+F12
- 重命名:比如要修改一個方法名,可以選中后按
F2
,輸入新的名字,回車,會發現所有的文件都修改過了。 - 跳轉到下一個Error或Warning:當有多個錯誤時可以按
F8
逐個跳轉 - 查看diff 在explorer里選擇文件右鍵
Set file to compare
,然后需要對比的文件上右鍵選擇Compare with 'file_name_you_chose'
.
查找替換
- 查找
Ctrl+F
- 查找替換
Ctrl+H
- 整個文件夾中查找
Ctrl+Shift+F
匹配符: *
to match one or more characters in a path segment?
to match on one character in a path segment**
to match any number of path segments ,including none{}
to group conditions (e.g.{**/*.html,**/*.txt}
matches all html and txt files)[]
to declare a range of characters to match (e.g.,example.[0-9]
to match onexample.0
,example.1
, …
顯示相關
- 全屏:
F11
- zoomIn/zoomOut:
Ctrl + =
/Ctrl + -
- 側邊欄顯/隱:
Ctrl+B
- 側邊欄4大功能顯示:
- Show Explorer
Ctrl+Shift+E
- Show Search
Ctrl+Shift+F
- Show Git
Ctrl+Shift+G
- Show Debug
Ctrl+Shift+D
- Show Explorer
- Show Output
Ctrl+Shift+U
其他
- 自動保存:File -> AutoSave ,或者
Ctrl+Shift+P
,輸入 auto
修改默認快捷鍵
File -> Preferences -> Keyboard Shortcuts
修改keybindings.json
,我的顯示在這里C:\Users\Administrator\AppData\Roaming\Code\User\keybindings.json
1
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
// Place your key bindings in this file to overwrite the defaults
[ //ctrl+space被切換輸入法快捷鍵占用 { "key": "ctrl+alt+space", "command": "editor.action.triggerSuggest", "when": "editorTextFocus" }, // ctrl+d刪除一行 { "key": "ctrl+d", "command": "editor.action.deleteLines", "when": "editorTextFocus" }, { "key": "ctrl+shift+k", //與刪除一行的快捷鍵互換了:) "command": "editor.action.addSelectionToNextFindMatch", "when": "editorFocus" }, //ctrl+shift+/多行注釋 { "key":"ctrl+shift+/", "command": "editor.action.blockComment", "when": "editorTextFocus" } ] |
插件
新版本支持插件安裝了
插件市場 https://marketplace.visualstudio.com/#VSCode
安裝插件
F1
輸入 extensions
點擊第一個開始安裝或升級,或者也可以 Ctrl+P
輸入 ext install
進入
點擊第二個會列出已經安裝的擴展,可以從中卸載
from: http://blog.csdn.NET/u010019717/article/details/50443970