Sublime Forum

Ctrl-p and Ctrl-n in Goto Anything result and related lists

#1

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?

0 Likes

Sublime Text 2 with Vim keybindings?
#2

DOUBLE POST DELETED.

0 Likes

#3

TRIPLE POST DELETED

0 Likes

#4
  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.

  1. 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

0 Likes

#5

What have I done!? :blush: Sorry about the spam…

0 Likes

#6

[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?

0 Likes

#7

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.

0 Likes

#8

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. :smile:

0 Likes