# VS Code でターミナルとエディターを往復するキーバインディング
Table of Contents
- ターミナルにフォーカスが当たっているとき
cmd+k eでエディタグループにフォーカスする
- エディタ内にフォーカスが当たっているとき
cmd+k tでターミナルにフォーカスする
- サイドバーにフォーカスが当たっているとき
cmd+k eでエディタグループにフォーカスする- エディタグループとサイドバー間でスイッチしたい
{ "key": "cmd+k e", "command": "workbench.action.focusActiveEditorGroup", "when": "terminalFocus || sideBarFocus" }, { "key": "cmd+k t", "command": "workbench.action.terminal.focus", "when": "editorTextFocus" }余談
GitHub Copilot Chat (モデルは Claude 3.5 Sonnet)でこのように聞いたらシュッと作ってくれた。便利
create a VS Code keybindings
- when focused on terminal, press command + K, E, switch to the active editor groups- when focused on editor, press command + K, T, switch to the terminal
// さらに追加で質問In addition, I want to add the keybindings like this:
- when focused on open edditors view, press command + K, E, switch to the active editor groups元々 cmd+k e はエクスプローラーの Open Editors にフォーカスするようになっている
Explorer: Focus on Open Editors View今回設定したものはあくまでターミナルにフォーカスしているときのみ。なので例えばエディタ内でフォーカスしているときは cmd+k e で元々の Open Editors へのフォーカスになる
さらに Open Editors (サイドバー)からエディタに戻れるようにしたかったので Cmd+k e でスイッチできるようにした
Copilot Chat にフォーカスを合わせる
以下のように設定すると cmd+k l で Copilot Chat にフォーカスを合わせることができる(Cursor の場合は cmd+y)
{ "key": "cmd+k l", "command": "workbench.panel.chat.view.copilot.focus" }