VS Code 配置刪除左邊單詞快捷鍵(同Sublime 和 Atom)


VS Code 中刪除一行的快捷鍵默認是 cmd + shift + k,或者使用簡介 cmd + x,對於一個長期使用 Sublime 和 Atom 的程序猿來說,在VS Code 上刪除行,特別是 刪除光標左邊單詞的 的操作是十分不習慣的(一度想要為此放棄VS Code...),百度上折騰了一大圈,最后還是自己動手修改了快捷鍵,這下寫代碼舒坦了,貼一下快捷鍵的配置過程。

 

1. cmd + K + S,呼出快捷鍵配置界面,如下

2. 輸入要修改的快捷鍵(支持模糊搜索),這里我要修改的是 deleteLeft

3. 選擇相關的快捷鍵,點擊 Keybinding 對應的快捷鍵,會彈出修改框

4. 在輸入框中輸入想要改成的快捷鍵,在右邊會自動生成對應的快捷鍵 json 文件(會覆蓋默認快捷鍵)

5. 保存 keybinding.json 文件,回到代碼中測試,大功告成。

 

當然,直接把下面的配置文件復制到 keybinding.json 中然后保存也是可以的。

// Place your key bindings in this file to overwrite the defaults
[
    {
        "key": "cmd+backspace",
        "command": "deleteLeft",
        "when": "textInputFocus && !editorReadonly"
    },
    {
        "key": "ctrl+backspace",
        "command": "-deleteLeft",
        "when": "textInputFocus && !editorReadonly"
    },
    {
        "key": "ctrl+h",
        "command": "-deleteLeft",
        "when": "textInputFocus && !editorReadonly"
    },
    {
        "key": "shift+backspace",
        "command": "-deleteLeft",
        "when": "textInputFocus && !editorReadonly"
    },
    {
        "key": "cmd+backspace",
        "command": "deleteWordLeft",
        "when": "textInputFocus && !editorReadonly"
    },
    {
        "key": "alt+backspace",
        "command": "-deleteWordLeft",
        "when": "textInputFocus && !editorReadonly"
    }
]

 

 


免責聲明!

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



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