Visual Studio Code 是目前最好用的代碼編輯器之一。它提供了許多開箱即用的功能以及豐富的第三方擴展,本文將分享常用的 VS Code 快捷鍵,助你提高開發效率!
Windows/Linux : ctrl + shift + /
macOS : command + shift + /
折疊/展開代碼塊:用于折疊或展開當前選中的代碼塊。
Windows/Linux : ctrl + shift + [ 折疊,ctrl + shift + ] 展開
macOS : ctrl + shift + [ 折疊,ctrl + shift + ] 展開
折疊/展開代碼塊和子代碼塊:一次性折疊或展開整個代碼塊及其所有子代碼塊。
Windows/Linux : ctrl + K 然后按 [ 折疊,ctrl + K 然后按 ] 展開
macOS : ctrl + K 然后按 [ 折疊,ctrl + K 然后按 ] 展開
導航到錯誤和警告處:快速導航到下一個錯誤或警告處,以便進行修復。
Windows/Linux:F8
macOS:F8 + fn
Windows/Linux: ctrl + ,
macOS: command + ,
切換側邊欄:控制側邊欄(通常包含文件瀏覽器、搜索、大綱等)的顯示或隱藏,提供更多或更少的屏幕空間。
Windows/Linux: ctrl + B
macOS: command + B
導航選項卡:在已打開的編輯器選項卡之間循環切換,使用戶能夠快速訪問不同的文件或代碼段。
Windows/Linux: ctrl + shift + tab
macOS: ctrl + shift + tab
導航選項卡組:快速切換到特定的選項卡組,或者通過創建新的選項卡組來組織和管理打開的文件。
Windows/Linux : ctrl + 1(第一個選項卡組)、ctrl + 2(第二個選項卡組)等
macOS:command + 1(第一個選項卡組)、command + 2(第二個選項卡組)等
打開終端:在內部打開集成終端,許用戶直接在編輯器中運行命令行工具、腳本或程序。
Windows/Linux: ctrl + J
macOS: command + J
打開命令面板:打開命令面板,可以在其中搜索并執行各種命令,如打開文件、保存、關閉等。
Windows/Linux: ctrl + shift + P
macOS: command + shift + P
Windows/Linux : ctrl + D
macOS : command + D
選擇所有查找結果:如果想要使用查找功能對所有查找結果進行批量操作或修改,可以使用此快捷鍵來一次性選擇文件中所有匹配的結果。
Windows/Linux: alt + enter
macOS: option + enter
Windows/Linux : ctrl + shift + L
macOS : command + shift + L
選擇當前詞的所有匹配項:當光標位于某個單詞上時,自動選中當前文件中該單詞的所有出現位置。
Windows/Linux: ctrl + F2
macOS: command + F2 + fn
選擇直到單詞的結尾:擴展當前選擇,直到當前單詞的末尾。
Windows/Linux : shift + end
macOS : shift + option + →
通過拖動鼠標選擇多行代碼:使用鼠標拖動選擇多行代碼時,此快捷鍵允許選擇部分行,而不是整行。
Windows/Linux : shift + alt + 拖動光標
macOS : shift + option + 拖動光標
使用箭頭鍵選擇多行代碼:在不移動光標的情況下,使用箭頭鍵配合修飾鍵來選擇多行代碼。
Windows/Linux : ctrl + shift + alt + 箭頭鍵(→, ←, ↑, ↓)
macOS : command + shift + option + 箭頭鍵(→, ←, ↑, ↓)
Windows/Linux : ctrl + alt + ↓(向下插入),ctrl + alt + ↑(向上插入)
macOS : command + option + ↓(向下插入),command + option + ↑(向上插入)
撤銷光標插入:撤銷最近一次插入的光標,而不影響其他光標位置。
Windows/Linux : ctrl + U
macOS : command + U
在選中代碼的末尾插入光標:在選中的文本塊中的每一行末尾都插入一個光標,方便進行批量編輯。
Windows/Linux : shift + alt + I
macOS : shift + option + I
Windows/Linux : shift + alt + ↓(向下復制),shift + alt + ↑(向上復制)
macOS : shift + option + ↓(向下復制),shift + option + ↑(向上復制)
代碼縮進:調整選中代碼塊的縮進級別,或調整光標所在行的縮進。
Windows/Linux : ctrl + [(減少縮進),ctrl + ](增加縮進)
macOS:command + [(減少縮進),command + ](增加縮進)
切換代碼注釋:對光標所在行或選中代碼塊進行注釋或取消注釋。
Windows/Linux: ctrl + /
macOS: command + /
切換代碼塊注釋:將選中的多行代碼注釋為塊注釋(如 /* ... */)。
Windows/Linux : shift + alt + A
macOS : shift + option + A
代碼格式化:對整個文件或選中代碼塊進行格式化,以符合編程語言的約定。
格式化整個文件:Windows/Linux ctrl + shift + F,macOS option + shift + F
格式化選中代碼:Windows/Linux ctrl + K 然后 ctrl + F,macOS command + K 然后 command + F
快速修復錯誤:當檢測到可快速修復的錯誤或警告時,使用此快捷鍵直接進行修復。
Windows/Linux : ctrl + .
macOS : command + .
重命名:快速重命名多個變量、函數或類。
Windows/Linux:F2
macOS:F2 + fn
刪除空白:刪除當前文件中多余的空行和空格。
Windows/Linux : ctrl + K 然后 X
macOS : command + K 然后 X
更改編程語言:手動設置或更改當前文件的編程語言。
Windows/Linux : ctrl + K, 然后按 M
macOS : command + K,然后按 M
Windows/Linux : alt + F12
macOS : option + F12 + fn
切換建議:當寫代碼時,VS Code 會根據當前的上下文提供可能的代碼補全選項。這個快捷鍵可以快速切換 VS Code 的代碼建議。
Windows/Linux: ctrl + I
macOS : command + I
最后,附上在 Windows、Linux、macOS 系統中 VS Code 的快捷鍵:
圖片
圖片
本文鏈接:http://www.tebozhan.com/showinfo-26-93508-0.htmlVS Code 常用快捷鍵大全
聲明:本網頁內容旨在傳播知識,若有侵權等問題請及時與本網聯系,我們將在第一時間刪除處理。郵件:2376512515@qq.com