Is it possible to use Ctrl-p and Ctrl-n (Emacs-style up/down cursor movement commands) in the Goto Anything result list, and other similar lists? At the moment it looks like I have to use the arrow keys to select a file in the list. I have mapped Ctrl-p and Ctrl-n globally in Mac OS X to mean cursor up/down, but for some reason it doesnât work in ST2. Can I map this manually in the keymap?
Ctrl-p and Ctrl-n in Goto Anything result and related lists
- Mappings to scroll up/down Goto Anything
I donât think this was even possible in v1.x for the quick panel, except in âcommandModeâ, which isnât implemented for v2 yet. Iâve wanted this for a long time too.
- Mappings for cursor up/down behavior
This is possible now:
{ "keys": "alt+n"], "command": "move", "args": {"by": "lines", "forward": false} },
{ "keys": "alt+p"], "command": "move", "args": {"by": "lines", "forward": true} }
]
(Iâve used the modifier âaltâ because Sublime makes heavy use of âctrlâ, but youâre free to override as many default settings as you like!)
Copy this to your Preferences | User Key Bindings file (Windows; I suppose menus are identical across platforms). Note that there isnât anything particular to cursor keys; Sublime just understands âcommandsâ (âupâ and âdownâ are the internal names for cursor key up and cursor key down; check the bindings in Preferences | Default Key Bindings).
HTH
Guillermo
[quote=âguillermoooâ]1) Mappings to scroll up/down Goto Anything
I donât think this was even possible in v1.x for the quick panel, except in âcommandModeâ, which isnât implemented for v2 yet. Iâve wanted this for a long time too.[/quote]
Dang, thatâs a shame. Reaching for the arrow keys for such a common operation really messes with my flow, since I have grown used to being able to do all my navigation without leaving the touch typing positions. And Goto Anywhere is one of those things that will be used all the time.
It seems to me that moving up and down in the Goto Anywhere result list should be possible with whatever key combos the user has bound to âmove cursor up/downâ. Is there an existing feature request for this or should I just go ahead and create one?
I just realised that there is a context in ST2 for whether or not the quick panel is open! So the only thing thatâs keeping me from mapping ctrl-p and ctrl-n to next/previous entry in the list is a command to move up and down in the quick panel.
Jon, would you mind sharing your thoughts on whether that will be possible in the future? I understand that this may seem like an obscure, insignificant detail, but itâs the only thing keeping me from navigating completely from the touch positions, and thatâs kind of a big deal to me.
It must have taken me a whole hour or more to try to find this related information (maybe I used bad keywords?). And it seems itâs really not a commonly asked question.
But here it goes, I suddenly got inspired and used sublime.log_commands(True)
to figure out what commands it was used, and created a simple key-binding solution here:
{ "keys": "alt+j"], "command": "move", "args": {"by": "lines", "forward": true}, "context":
{ "key": "overlay_visible", "operator": "equal", "operand": true}
]
},
{ "keys": "alt+k"], "command": "move", "args": {"by": "lines", "forward": false}, "context":
{ "key": "overlay_visible", "operator": "equal", "operand": true}
]
},
I used j and k here to move up and down in the list when command palette is open. It works for other overlays too. You can change that to n and p if you like. This seems works fine with ST3 on Windows. I hope itâs useful even though it is a very old topic.