自分用メモ。タイトルのまんま。
わたしは普段shellはbash、プログラミングするときのエディタはVSCodeを使っています。端末上でbashを使うときのキーバインドはemacsっぽいやつです。より正しい表現をするとbashが内部的に使っているreadlineのediting-modeがemacsになっています。
VSCodeはterminal機能を持っていますが、一部のキー入力をVSCodeが食べてしまうので、使用感が普通の端末とは異なってストレスフルです。このため、端末を使いたければVSCodeのterminalは使わずに別途端末ソフトウェアを立ち上げていました。これが嫌だったのでちょっと調べてterminalのキーバインドを変えました。
やりかたは簡単です。
Ctrl+Shift+p
でPreferences: Open Keyboard ShortCuts (JSON)
を選択して"keybindings.json"を開く- ファイルに以下の内容を追加。
[ { "key": "ctrl+p", "command": "cursorUp", "when": "terminalFocus" }, { "key": "ctrl+n", "command": "cursorDown", "when": "terminalFocus" }, { "key": "ctrl+f", "command": "cursorRight", "when": "terminalFocus" }, { "key": "ctrl+b", "command": "cursorLeft", "when": "terminalFocus" }, { "key": "ctrl+a", "command": "cursorHome", "when": "terminalFocus" }, { "key": "ctrl+e", "command": "cursorEnd", "when": "terminalFocus" }, { "key": "ctrl+d", "command": "deleteRight", "when": "terminalFocus" }, { "key": "ctrl+h", "command": "deleteLeft", "when": "terminalFocus" }, { "key": "ctrl+k", "command": "deleteAllRight", "when": "terminalFocus" }, { "key": "ctrl+m", "command": "type", "args": { "text": "\n"}, "when": "terminalFocus", } ]
わたしが普段つかうキーバインドしか気にしてないので、人によってはこれでも足りないと思います。そのときは適当に設定を追加してください。