emacs風のキーバインドをVSCodeにも導入する.
対象
Windowsを対象にしている.(Macでは何もしなくてもできるため)
やること
- emacsのカーソル移動,文字削除とかをできるようにしたい.
- VSCode内の本来の機能はできるだけ失わないようにしたい.
変更
VSCode内のkeybindings.jsonの中をいじってキーバインドを変更する.
既存のキーと衝突するときは既存のものにAltを足して回避する.
keybindings.json
[
{
"key": "ctrl+p",
"command": "cursorUp",
"when": "editorTextFocus"
},
{
"key": "ctrl+alt+p",
"command": "workbench.action.quickOpenNavigateNext",
"when": "inQuickOpen"
},
{
"key": "ctrl+alt+p",
"command": "workbench.action.quickOpen"
},
{
"key": "ctrl+n",
"command": "cursorDown",
"when": "editorTextFocus"
},
{
"key": "ctrl+alt+n",
"command": "workbench.action.files.newUntitledFile"
},
{
"key": "ctrl+f",
"command": "cursorRight",
"when": "editorTextFocus"
},
{
"key": "ctrl+alt+f",
"command": "defaultSettings.action.focusSearch",
"when": "defaultSettingsEditor"
},
{
"key": "ctrl+alt+f",
"command": "actions.find"
},
{
"key": "ctrl+b",
"command": "cursorLeft",
"when": "editorTextFocus"
},
{
"key": "ctrl+alt+b",
"command": "workbench.action.toggleSidebarVisibility"
},
{
"key": "ctrl+a",
"command": "cursorHome",
"when": "editorTextFocus"
},
{
"key": "ctrl+alt+a",
"command": "editor.action.selectAll"
},
{
"key": "ctrl+e",
"command": "cursorEnd",
"when": "editorTextFocus"
},
{
"key": "ctrl+alt+e",
"command": "workbench.action.quickOpenNavigateNext",
"when": "inQuickOpen"
},
{
"key": "ctrl+alt+e",
"command": "workbench.action.quickOpen"
},
{
"key": "ctrl+k ctrl+k",
"command": "deleteAllRight",
"when": "editorTextFocus"
},
{
"key": "ctrl+d",
"command": "deleteRight",
"when": "editorTextFocus"
},
{
"key": "ctrl+h",
"command": "deleteLeft",
"when": "editorTextFocus"
},
{
"key": "ctrl+alt+h",
"command": "editor.action.startFindReplaceAction"
},
{
"key": "ctrl+h",
"command": "-editor.action.startFindReplaceAction"
}
]
感想
今のところなにも違和感なく使うことができている.ただウィンドウ内検索するときなど何も考えずにctrl+fを押してただカーソルが動くだけの時が時々発生する.
よく使う既存のショートカットは別に割り当てるのも必要なのかもしれない.