vscode 自定義快捷鍵


vscode 自定義快捷鍵

這兩天用vscode寫了下Python,感覺很舒服,只是快捷鍵不如人意,略作修改,放上來作為備份。smile~

主要更改:

代碼格式化   ctrl+alt+l
執行代碼    ctrl+enter
增加一行    shift+enter
刪除一行             ctrl+d
代碼提示             alt+/ 或 ctrl+j
復制一行代碼      ctrl+alt+up/down

用慣了Eclipse的人會覺得很熟悉,只有格式化代碼是Intellij的快捷鍵。

C:\Users\Administrator\AppData\Roaming\Code\User\keybindings.json

// 將鍵綁定放入此文件中以覆蓋默認值
[
    { //行選定
        "key": "ctrl+i",
        "command": "expandLineSelection",
        "when": "editorTextFocus"
    },
    { //重做
        "key": "ctrl+y",
        "command": "redo",
        "when": "editorTextFocus && !editorReadonly"
    },
    { //增加注釋行
        "key": "ctrl+k ctrl+c",
        "command": "editor.action.addCommentLine",
        "when": "editorTextFocus && !editorReadonly"
    },
    {
        "key": "ctrl+shift+k", //與ctrl+d互換了
        "command": "editor.action.addSelectionToNextFindMatch",
        "when": "editorFocus"
    },
    { //塊注釋
        "key": "ctrl+shift+/", //shift+alt+a
        "command": "editor.action.blockComment",
        "when": "editorTextFocus && !editorReadonly"
    },
    {
        "key": "ctrl+alt+down", //shift+alt+down改為ctrl+alt+down
        "command": "editor.action.copyLinesDownAction",
        "when": "editorTextFocus && !editorReadonly"
    },
    {
        "key": "ctrl+alt+up", //shift+alt+up改為ctrl+alt+up,互換!
        "command": "editor.action.copyLinesUpAction",
        "when": "editorTextFocus && !editorReadonly"
    },
    {
        "key": "ctrl+d", //互換了 ctrl+shift+k
        "command": "editor.action.deleteLines",
        "when": "editorTextFocus && !editorReadonly"
    },
    {
        "key": "ctrl+alt+l", // 格式化代碼,由shift+alt+f改為ctrl+alt+l,互換!
        "command": "editor.action.formatDocument",
        "when": "editorHasDocumentFormattingProvider && editorTextFocus && !editorReadonly"
    },
    {
        "key": "ctrl+k ctrl+f",
        "command": "editor.action.formatSelection",
        "when": "editorHasDocumentSelectionFormattingProvider && editorHasSelection && editorTextFocus && !editorReadonly"
    },
    {
        "key": "f12",
        "command": "editor.action.goToDeclaration",
        "when": "editorHasDefinitionProvider && editorTextFocus && !isInEmbeddedEditor"
    },
    {
        "key": "ctrl+f12",
        "command": "editor.action.goToImplementation",
        "when": "editorHasImplementationProvider && editorTextFocus && !isInEmbeddedEditor"
    },
    {
        "key": "shift+alt+up", // shift+alt+up互換,原為ctrl+alt+up
        "command": "editor.action.insertCursorAbove",
        "when": "editorTextFocus"
    },
    {
        "key": "shift+alt+down", // shift+alt+down互換,原為ctrl+alt+up
        "command": "editor.action.insertCursorBelow",
        "when": "editorTextFocus"
    },
    {
        "key": "shift+enter", //ctrl+enter改為shift+enter
        "command": "editor.action.insertLineAfter",
        "when": "editorTextFocus && !editorReadonly"
    },
    // {
    //     "key": "ctrl+shift+enter",
    //     "command": "editor.action.insertLineBefore",
    //     "when": "editorTextFocus && !editorReadonly"
    // },
    {
        "key": "alt+/", // ctrl+space 改為alt+/
        "command": "editor.action.triggerSuggest",
        "when": "editorHasCompletionItemProvider && editorTextFocus && !editorReadonly"
    },
    {
        "key": "shift+alt+f", //與shift+alt+f互換,原為shift+alt+f
        "command": "rest-client.rerun-last-request",
        "when": "editorTextFocus && editorLangId == 'http'"
    },
    {
        "key": "shift+alt+f", //與shift+alt+f互換,原為shift+alt+f
        "command": "rest-client.rerun-last-request",
        "when": "editorTextFocus && editorLangId == 'plaintext'"
    },
    {
        "key": "shift+alt+f", //與shift+alt+f互換,原為shift+alt+f
        "command": "rest-client.rerun-last-request",
        "when": "resourceScheme == 'rest-response'"
    },
    {
        "key": "ctrl+.", //原為ctrl+j
        "command": "workbench.action.togglePanel"
    },
    {
        "key": "ctrl+enter", //原為ctrl+shift+b
        "command": "workbench.action.tasks.build"
    } ]

 

 

參考鏈接:

用VSCode寫python的正確姿勢

另:如果想偷懶,有個code runner的插件可以試一下~


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM