Jump to content

Vim Navigation Binding


johnku

Recommended Posts

  • 8 months later...

I've got that working with Keyboard Maestro :) For the impatient (who also use KM), here's how it's done:

 

1. Create a new Macro group and choose "Alfred 2" from "Available in the following applications". 

2. Create a new macro called "Go up"

3. Choose the trigger ^k (ctrl + k) and change from "is pressed" to "is down"

4. Add a new action "Type a Keystroke" with ^p (ctrl + p)

 

 

Done. Do the analogue procedure for "Go down". You can even add a shortcut for the return key, like ^l (l corresponds to right in vim) or ^m (just like in the terminal) using a similar procedure.

 

Although that works pretty fine, a native feature is sure better.

Link to comment
Share on other sites

  • 6 months later...
  • 3 years later...

@snoblenet I also cannot get it working with BTT.

 

Program-specific key bindings have previously worked well for me in BTT... I wonder if there's something about keyboard input to Alfred that's different from most applications?

 

Custom scrolling keys would be a really helpful feature since macbookpro arrow keys so tiny and difficult to use. 

Link to comment
Share on other sites

  • 1 year later...
On 12/25/2017 at 3:13 PM, xxyxxyxyx1 said:

I wonder if there's something about keyboard input to Alfred that's different from most applications?

 

Alfred doesn’t take focus. So Alfred-specific configurations in BTT etc. that rely on detecting the active app aren’t going to work.

 

31 minutes ago, reviolito said:

Could you please add this feature to change Ctrl + N/P to Ctrl +J/K

 

Why change? No reason you can’t have both.

Link to comment
Share on other sites

I don't understand what you mean by "No reason you can't have both". I think it would be great to give the user an option to choose which shortcuts will take him/her to the next or previous search result. Right now it's Ctrl + N for next and Ctrl + P for the previous item in the Alfred search result. I want to go to next item using Ctrl + J and previous item using Ctrl + K. There is no convenient method to achieve it using BTT or karabiner elements. So I think this should be added to the app.

Link to comment
Share on other sites

16 minutes ago, reviolito said:

As long as I can choose which keys to use to navigate in search results I would be happy.

 

Ah, right. I think I misunderstood your previous comment.

 

I thought you wanted the developer to remove ^N and ^P and replace them with ^J and ^K (as @johnku originally requested), not add an option to change the key bindings.

Link to comment
Share on other sites

 

On 2/18/2019 at 1:30 AM, deanishe said:

I thought you wanted the developer to remove ^N and ^P and replace them with ^J and ^K (as @johnku originally requested), not add an option to change the key bindings.

 

 

I see! Then maybe I shouldn't have posted it here and I should make a new post for this request?

Link to comment
Share on other sites

4 hours ago, reviolito said:

I see! Then maybe I shouldn't have posted it here and I should make a new post for this request?

 

I don't think that's necessary, tbh. The new posts in this thread will have bumped it back to the top of the forum, and the Alfred team are almost certainly following the discussion, even if they haven't weighed in yet.

 

If I had to guess, I don't think an option will be forthcoming, but I'd say there's a decent chance of getting ^J and ^K added as additional keyboard shortcuts.

 

Unless Andrew is an emacs guy, of course…

Edited by deanishe
Link to comment
Share on other sites

  • 1 month later...
  • 1 month later...

Hey, are you planning to address this on the new version? I use the cmd+space (search - launch or focus) at least an order of magnitude more frequently then the rest of the features combined. Some flexibility/customization would make this so much better 🙂

Edited by aktupon
Link to comment
Share on other sites

  • 3 weeks later...
  • 4 months later...

If anyone wants to get similar functionality, I did this by using 2 Karabiner-Elements complex modifications. I found one that let me bind my caps lock to esc if pressed once and ctrl if pressed with other keys. Then I found another one that has left ctrl hjkl to arrow keys.

 

https://pqrs.org/osx/karabiner/complex_modifications/#caps_lock

 

^ Choose "Change caps_lock to control if pressed with other keys, to escape if pressed alone"

 

https://pqrs.org/osx/karabiner/complex_modifications/#ctrl_plus_hjkl_to_arrow_keys

Link to comment
Share on other sites

  • 1 year later...
  • 8 months later...

A picture is worth a thousand words. As I am totally new to Alfred it took me a few minutes to realize what @Mr Pennyworth explained and then take my first step in creating my first workflow.  This is intended to help other newbs grok how to do this within Alfred with no additional software required.

 

Workflow:

 

Effectively remaps ^N [Next] and ^P [Previous] to ViM keybindings.

  • Trigger Hotkey [CTRL+J] -> Outputs -> Dispatch Key Combo [Ctrl+N]
  • Trigger Hotkey [CTRL+K] -> Outputs -> Dispatch Key Combo [Ctrl+P]

image.png.df8f8d74909a1b055f2ae708993c3696.png

Link to comment
Share on other sites

  • 4 weeks later...

Thanks for these great tips, very handy. I tried to use the same method to also trigger going back and forth in query history using my preferred shortcuts Ctrl+O and Ctrl+I to dispatch key combos Ctrl+↑ and Ctrl+↓, respectively, but this does not work, any suggestions? I'm using Alfred 4.5.1 on macOS 11.5.

 

Link to comment
Share on other sites

  • 2 weeks later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...