karabiner

How to exchange square bracket and curly bracket (karabiner)


On Karabiner rules (https://pqrs.org/osx/karabiner/complex_modifications/), there is a rule for Exchange paren and square bracket but there is no rule for Exchange square bracket and curly braket.

[Q] How to exchange square bracket and curly bracket through Karabiner or any alternative?

Wanted exchange:


Solution

  • This code works for me

    {
      "description": "Swap {} and []",
      "manipulators": [
        {
          "type": "basic",
          "from": {
            "key_code": "open_bracket"
          },
          "to": [
            {
              "modifiers": ["left_shift"],
              "key_code": "open_bracket"
            }
          ]
        },
        {
          "type": "basic",
          "from": {
            "key_code": "open_bracket",
            "modifiers": {
              "mandatory": ["left_shift"]
            }
          },
          "to": [
            {
              "key_code": "open_bracket"
            }
          ]
        },
        {
          "type": "basic",
          "from": {
            "key_code": "close_bracket"
          },
          "to": [
            {
              "modifiers": ["left_shift"],
              "key_code": "close_bracket"
            }
          ]
        },
        {
          "type": "basic",
          "from": {
            "key_code": "close_bracket",
            "modifiers": {
              "mandatory": ["left_shift"]
            }
          },
          "to": [
            {
              "key_code": "close_bracket"
            }
          ]
        }
      ]
    }
    

    edit: also now in complex mod list https://pqrs.org/osx/karabiner/complex_modifications/#exchange_square_brackets_and_curly_brackets