Cerebro: Vim like movement keys

Created on 27 Feb 2017  Â·  10Comments  Â·  Source: cerebroapp/cerebro

Hi, just installed cerebro and I have to say that I'm quite enjoying it. I was opening this issue to check whether you'd be happy for me to implement a feature that I would quite like to have.

I use spacemacs and vimium and am quite used to using vim-like command keys to navigate around. I was wondering if it would be ok for me to add these to cerebro.

For instance, Ctrl+j would go down Ctrl+k would go up, Ctrl+h would go left and Ctrl+l would go right.

If it's not wanted generally we could put them behind a feature flag in the settings. What do you think?

Most helpful comment

It doesn't have to be one or another, the shortcuts Ctrl+j/k/h/l/n/p are unused now and can be added right away, for everyone, not controlled by any settings - and for some people that would be enough.

The command mode is a different beast, it has to be hidden in the settings and disabled by default, otherwise people will just be confused a lot. But it potentially provides much more control than a simple navigation.

All 10 comments

I'd love to see such alternative shortcuts. I personally think there is no reason to hide them behind a feature flag, as currently they do nothing.

I'd just add j/k/l/h hotkeys (without ctrl), but I'm not sure what to do with input focus. In this case we should introduce two modes (like in vim). Now I see only one way is to add another flag to settings. If this flag is on, then:

1) When you open Cerebro window it is in insert mode
2) After you input something and use esc it switches to command mode
3) In command mode j/k/l/h keys are used for navigation, o is equal of enter, i switches back to insert mode, esc closes the window.

What do you think, @maximbaz @mijoharas?

A whole separate mode is no doubt a much more powerful concept, I'm sure there will be other ideas what could we do in the command mode apart from navigating with jklh.

Just one wish: do not make esc from command mode close the window, let it better be q.

I'm used too much to the fact that hitting esc multiple times in vim does not hurt and just keeps me in normal mode. Even if I'm in normal mode already, due to my muscle memory I sometimes hit esc again (to be sure that I'm in normal mode) and then begin navigating with jklh — I don't want this to close the window 🙂

Would love this.

On a related note, the Emacs-like ctrl+p / ctrl+n for up and down respectively would be great. These shortcuts are prevalent throughout OS X, though I'm running Cerebro on a Linux box and I miss them (coming from Alfred). Different issue?

:+1: command mode is even better in my opinion, as that's nice and natural to me. Thanks!

I'd vote for hybrid-mode: Ctrl-h/j/k/l Ctrl-n/p (and maybe ctrl-f/b). Introducing modes to an app is such a burden from maintenance point of view.

It doesn't have to be one or another, the shortcuts Ctrl+j/k/h/l/n/p are unused now and can be added right away, for everyone, not controlled by any settings - and for some people that would be enough.

The command mode is a different beast, it has to be hidden in the settings and disabled by default, otherwise people will just be confused a lot. But it potentially provides much more control than a simple navigation.

I like this idea of having mixed shortcuts, like lightweight vim-mode and hardcore vim-mode hidden in settings! In this case everyone should be happy:)

Ok, summarizing:

There are two steps of implementation.

Lightweight vim-mode

On first step we just add few more shortcuts:
ctrl+hjkl – navigate in results (the same as arrows now)
ctrl+o – select (=== enter)

Hardcore vim-mode

  • We add a checkbox to settings to active this feature
  • We introduce two modes:

Insert mode

It works, like Cerebro works now. Only one exception esc switches app to command mode, instead of closing the window

Command mode

In this mode you can't change input term, but you have more powerfull commands, like

hjkl – navigate in results (the same as arrows in insert mode)
o – select (=== enter)
i – switch app back to insert mode
q – close the window

Any more thoughts?

So, first stage is out in release 0.2.8

Was this page helpful?
0 / 5 - 0 ratings

Related issues

wonzbak picture wonzbak  Â·  6Comments

lubien picture lubien  Â·  5Comments

rafa-acioly picture rafa-acioly  Â·  6Comments

tunnckoCore picture tunnckoCore  Â·  6Comments

mijoharas picture mijoharas  Â·  3Comments