🔖

MacのVSCodeでもWindows/Linuxと同じようにalt+左矢印、右矢印でnavigation移動がしたい!

に公開

久々にMacBookProを仕事で支給されて使ったら地味に困ったので自分向けメモ

VSCodeなどで開発、ソース確認をしていて定義先に移動したり戻るときにWindowsの標準のキー割当はAlt+←Alt+→です。自前のLinux環境でもショートカットの割り当てをこちらに変えているんですが、Macだと^(control)+-^(control)+_ とイマイチ感覚的ではないのと、VSCode側で^(control)+←^(control)+→ のコンビネーションキーが認識出来ない問題があったのでなんとか対応します。
ところで、Macの以前のVSCodeのコンビネーションコードはOption+←Option+→だったようですがどのタイミングで変わったんでしょうか?

設定:
Karabiner-Element

設定内容

{
    "description": "[vscode]ctrl(alt)+←キーでnavigateBackする",
    "manipulators": [
        {
            "conditions": [
                {
                    "bundle_identifiers": [
                        "^com.microsoft.VSCode"
                    ],
                    "type": "frontmost_application_if"
                }
            ],
            "from": {
                "key_code": "left_arrow",
                "modifiers": { "mandatory": ["control"] }
            },
            "to": {
                "key_code": "hyphen",
                "modifiers": ["control"]
            },
            "type": "basic"
        }
    ]
}
{
    "description": "[vscode]ctrl(alt)+→キーでnavigateForwardする",
    "manipulators": [
        {
            "conditions": [
                {
                    "bundle_identifiers": [
                        "^com.microsoft.VSCode"
                    ],
                    "type": "frontmost_application_if"
                }
            ],
            "from": {
                "key_code": "right_arrow",
                "modifiers": { "mandatory": ["control"] }
            },
            "to": {
                "key_code": "international1",
                "modifiers": ["control"]
            },
            "type": "basic"
        }
    ]
}

Macのキーボードショートカットは変なところで独特なところがあるので複数OS使っている身からすると何気にしんどい…。

Discussion