Search code examples
sublimetext2key-bindings

Sublime Text 2 sidebar context: Vim-like key bindings for sidebar navigation


Does anyone know the "context" for the Sublime Text 2 side bar, or have any idea how to find the context?

I use Sublime Text 2 in Vintage mode, and along with several custom key bindings (and VintageEx) rarely have to leave the home row. Re-binding 'j', 'k', and the likes without specifying a context carries over to Insert mode in the edit window(s) so that there is movement rather than typing j or k. To be more concrete, any thoughts on what should replace '???' in this mapping:

{ "keys": ["j"], "command": "move", "args": {"by": "lines", "forward": true} , "context": [{"key": "???"}] }

to use 'j' in place of the down arrow in the sidebar?

Many thanks!


Solution

  • Here you go. Just add this to your Preferences->Key Bindings-User.

    { "keys": ["h"], "command": "move", "args": {"by": "characters", "forward": false}, "context":
        [ {"key": "control", "operand": "sidebar_tree"} ]
    },
    { "keys": ["j"], "command": "move", "args": {"by": "lines", "forward": true}, "context":
        [ {"key": "control", "operand": "sidebar_tree"} ]
    },
    { "keys": ["k"], "command": "move", "args": {"by": "lines", "forward": false}, "context":
        [ {"key": "control", "operand": "sidebar_tree"} ]
    },
    { "keys": ["l"], "command": "move", "args": {"by": "characters", "forward": true}, "context":
        [ {"key": "control", "operand": "sidebar_tree"} ]
    }
    

    Hope that helps!