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