一、vscode快捷鍵
1、ctrl + n:新建文件
使用該快捷鍵可以快速新建文件,無需手動在資源管理器中右鍵創建文件。
{
"key": "ctrl+n",
"command": "workbench.action.files.newUntitledFile"
}
2、ctrl + shift + n:新建窗口
使用該快捷鍵可以快速新建一個新的vscode窗口。
{
"key": "ctrl+shift+n",
"command": "workbench.action.newWindow"
}
3、ctrl + p:快速打開文件
使用該快捷鍵可以快速打開項目中的文件,輸入文件名或路徑即可查找到需要打開的文件。
{
"key": "ctrl+p",
"command": "workbench.action.quickOpen"
}
4、ctrl + shift + p:命令面板
使用該快捷鍵可以打開命令面板,可以通過輸入命令名稱來快速執行一些操作,比如格式化代碼等。
{
"key": "ctrl+shift+p",
"command": "workbench.action.showCommands"
}
5、ctrl + shift + t:打開最近關閉的文件
使用該快捷鍵可以打開最近關閉的文件,可以多次使用該快捷鍵來打開更早的已關閉的文件。
{
"key": "ctrl+shift+t",
"command": "workbench.action.reopenClosedEditor"
}
二、vscode代碼整理快捷鍵
1、shift + alt + f:格式化代碼
使用該快捷鍵可以快速格式化當前文件中的代碼。
{
"key": "shift+alt+f",
"command": "editor.action.formatDocument"
}
2、ctrl + shift + f:全局搜索
使用該快捷鍵可以在整個項目中搜索指定的關鍵字。
{
"key": "ctrl+shift+f",
"command": "workbench.action.findInFiles"
}
3、alt + up/down:上/下移當前行代碼
使用該快捷鍵可以將當前行的代碼向上或向下移動一行。
{
"key": "alt+up",
"command": "editor.action.moveLinesUpAction"
},
{
"key": "alt+down",
"command": "editor.action.moveLinesDownAction"
}
三、vscode格式化代碼快捷鍵
1、ctrl + k ctrl + f:格式化選中代碼
使用該快捷鍵可以格式化選中的代碼,只對選中的代碼生效。
{
"key": "ctrl+k ctrl+f",
"command": "editor.action.formatSelection"
}
2、ctrl + alt + shift + i:格式化整個文件
使用該快捷鍵可以格式化當前文件中的所有代碼。
{
"key": "ctrl+alt+shift+i",
"command": "editor.action.selectAll",
"when": "editorTextFocus"
}
四、vscode代碼提示快捷鍵
1、ctrl + space:基本代碼提示
使用該快捷鍵可以彈出基本的代碼提示,包括語言特定的關鍵字、方法等。
{
"key": "ctrl+space",
"command": "editor.action.triggerSuggest"
}
2、ctrl + shift + space:高級代碼提示
使用該快捷鍵可以彈出高級的代碼提示,可以給出更加智能化的建議。
{
"key": "ctrl+shift+space",
"command": "-editor.action.triggerSuggest"
}
五、vscode代碼縮進快捷鍵
1、shift + tab:取消縮進
使用該快捷鍵可以將當前游標所在行的代碼向左移動一個縮進的位置,即取消縮進。
{
"key": "shift+tab",
"command": "editor.action.outdentLines"
}
2、tab:增加縮進
使用該快捷鍵可以將當前游標所在行的代碼向右移動一個縮進的位置,即增加縮進。
{
"key": "tab",
"command": "editor.action.indentLines"
}
六、vscode對齊代碼快捷鍵
1、ctrl + ]/[:對齊代碼
使用該快捷鍵可以將選中的代碼塊或當前游標所在行的代碼塊對齊。
{
"key": "ctrl+]",
"command": "editor.action.indentLines"
},
{
"key": "ctrl+[",
"command": "editor.action.outdentLines"
}
七、vscode規範代碼格式快捷鍵
1、ctrl + f12:跳轉至定義
使用該快捷鍵可以快速跳轉至當前游標所在變數或方法的定義位置。
{
"key": "ctrl+f12",
"command": "editor.action.peekDefinition"
}
2、F12:跳轉至聲明
使用該快捷鍵可以快速跳轉至當前游標所在變數或方法的聲明位置。
{
"key": "f12",
"command": "editor.action.goToDeclaration"
}
八、vscode摺疊代碼快捷鍵
1、ctrl + shift + [:摺疊全部代碼塊
使用該快捷鍵可以摺疊當前文件中的所有代碼塊。
{
"key": "ctrl+shift+[",
"command": "editor.foldAll"
}
2、ctrl + shift + ]:展開全部代碼塊
使用該快捷鍵可以展開當前文件中所有被摺疊的代碼塊。
{
"key": "ctrl+shift+]",
"command": "editor.unfoldAll"
}
九、vscode代碼對齊快捷鍵
1、ctrl + alt + ]/[:基於對齊字元對齊代碼塊
使用該快捷鍵可以對選中的代碼塊進行對齊,以游標所在列為對齊基準。
{
"key": "ctrl+alt+]",
"command": "editor.action.alignBySemicolon",
"when": "editorTextFocus"
},
{
"key": "ctrl+alt+[",
"command": "-editor.action.alignBySemicolon",
"when": "editorTextFocus"
}
結語
在開發中,熟練掌握一些快捷鍵可以大大提高工作效率,尤其是對於開發密集型的工作場景來說,更是必不可少的工具。本文就介紹了vscode代碼規範快捷鍵的相關內容,希望對大家的開發工作有所幫助。
原創文章,作者:小藍,如若轉載,請註明出處:https://www.506064.com/zh-tw/n/155192.html