pqrs-org / Karabiner-Elements

Karabiner-Elements is a powerful utility for keyboard customization on macOS Sierra (10.12) or later.
https://pqrs.org/osx/karabiner/
The Unlicense
18.69k stars 836 forks source link

Simultaneous Vi mode - is this feature on the roadmap? #153

Closed bobobox closed 6 years ago

bobobox commented 8 years ago

First, thank you for your work on this incredibly useful tool, and and sorry to just post a basic question: Can @tekezo or anyone else familiar with the development of Karabiner-Elements give an idea of how far away the re-implementation of Simultaneous Vi mode is (or if it will ever be part of Elements?)

This was the major feature of Karabiner that I relied on, but I'm learning that it's a pretty unique thing.

Sorry, I'm not familiar with C++ and can't just read the source code to answer my own question :P

Thank you

Bobo

watsoncj commented 7 years ago

Hi @bobobox, I've hard-coded fn+hjkl here: https://github.com/watsoncj/Karabiner-Elements/commit/5531032a309fe99e7e153cb725b9f44a19da69c0

You may be able to hard-code simultaneous Vim mode with a similar approach.

paxl13 commented 7 years ago

@watsoncj I'd be interested to see how this could be done. My c++ is sadly quite rusty. I've been using the Simulatenous VI mode since so long I miss it soo much :) Thanks

paxl13 commented 7 years ago

Yep. there isn't a simple way to implment this as it rely on key chording... which would need to be implemented from ground up :(

jasonrudolph commented 7 years ago

I've been using the Simulatenous VI mode since so long I miss it soo much

Until Simultaneous VI Mode is available in Karabiner-Elements, I think we can approximate the functionality with Hammerspoon. If you can turn a blind eye to the code :see_no_evil::innocent:, the implementation in https://github.com/jasonrudolph/keyboard/pull/10 might meet your needs. That pull request isn't an exact port of Simultaneous VI Mode, but it may be close enough for you. If not, perhaps the code can serve as a starting point that you can customize as needed. :v:

Peeja commented 7 years ago

looks up from the macOS device driver docs

Hammerspoon, you say…

raineorshine commented 7 years ago

Thank you @jasonrudolph! That Super Duper mode was just what I needed to restore my previous Simultaneous VI settings. For those who are interested in just this feature, here were my exact steps:

  1. Install Hammerspoon
  2. Download init.lua and super.lua to ~/.hammerspoon/.
  3. Comment out all require statements in init.lua except the one to 'super'.

My final config is here. (Note: I changed the home row keys since I use a different keyboard layout.)

Peeja commented 7 years ago

Almost a year on and I still haven't managed a good replacement for __SimultaneousKeyPresses__. I used to use several of them: one on [SD], one on [DF], one on [ER], and one on [CV]. I'm finding the Hammerspoon solutions break down after a while and I need to reload the config several times a day to get them to keep running. I also can't see a good way to enable chords on [SD] and [DF] without conflicting with each other horribly.

I would be extremely grateful for a first class solution again in Karabiner Elements. My fingers feel like they've been broken for a year.

stifynsemons commented 7 years ago

Hi Peter,

SimultaneousKeyPresses is what I used extensively in Karabiner, and Karabiner-Elements supports this concept through the use of variables. It took me a while to get the hang of variables, because you have to take care of all the combinations of variables correctly. If you write the json file by hand, it is enormously complex and difficult to get right. It is actually more powerful than the set of functions available from Karabiner, but also more cumbersome.

Like in Karabiner, I have switched to scripting, and have a generic chording solution published at https://github.com/stifynsemons/ke-chording. Unfortunately, while it handles conflicts between variables correctly (my current file uses 58 variables and 327 multi-variable conditions), it ties in to my key-remapping at the moment, so it is only half-automatic at the moment.

I don't know specifically what you are looking for, but with it, you create a chord file, like sd the ds the df ⌫ fd ⌫

etc. I assume from the way that you wrote them, that you want sd and ds to do the same thing, so each spells out "the". There is a 1 for 1 correspondence between characters in the file and type characters, so keys without an ASCII symbol, like delete_or_backspace get a special Uni-code character, shown as ⌫ above. This is not documented yet.

Let me know what you want sd, df, er, and cv defined as and I will publish a version for it. Currently it can reliably use/produce a-z, 0-9, and the punctuation `-=[]\;',./ along with the space bar, arrow keys, delete, tab, and return with an MBP/touchbar keyboard.

Stephen Simmons

On Sun, Sep 17, 2017 at 11:13 AM, Peter Jaros notifications@github.com wrote:

Almost a year on and I still haven't managed a good replacement for SimultaneousKeyPresses. I used to use several of them: one on [SD], one on [DF], one on [ER], and one on [CV]. I'm finding the Hammerspoon solutions break down after a while and I need to reload the config several times a day to get them to keep running. I also can't see a good way to enable chords on [SD] and [DF] without conflicting with each other horribly.

I would be extremely grateful for a first class solution again in Karabiner Elements. My fingers feel like they've been broken for a year.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/tekezo/Karabiner-Elements/issues/153#issuecomment-330063261, or mute the thread https://github.com/notifications/unsubscribe-auth/AAkwms2pnciDSJE3VfjxJ6LO_MzMkW9Wks5sjVMkgaJpZM4KGnzp .

Peeja commented 7 years ago

@stifynsemons It looks like that's for translating chords to words, yes? What I'm trying to do is map a chord to mode, so for instance, [ER] + H/J/K/L is left/down/up/right, and [DF] + H/J/K/L moves between panes within a window. I've been using variables, but it just gets too complicated. I'm actually not certain it's possible to do the chording I want and type normally if I just press the chord characters as part of normal typing and don't hold them to press another key. __SimultaneousKeyPresses__ just did what I wanted perfectly.

(I should say that I'm eternally grateful for Karabiner, and I wouldn't have anything to miss in the first place if it weren't for the hard work that's gone into this amazing project. I fear my previous comment came out a bit entitled. I'm only frustrated because I feel like I've tasted the perfect keyboard setup and Sierra took it all away.) :)

stifynsemons commented 7 years ago

Hi Peter,

I showed examples chords into words, because you mentioned chords. But I have been playing with nested chords (manually), where an initial chord pair sets a mode, and creates an overlay set of keys (or chords) that take priority over the chords or keys that they replace. I had to manually extend conditions to make the overlays compatible with chords using the trigger chords.

The next step would be add a trigger generator to ke-chording, and to add the interlocks as well.

My remaining question is, how should you leave the mode?

In my hack, I used zx and xz as the nesting triggers, and either z or x would leave whatever nesting had been entered. An alternative would be to leave by ESC or some similar key.

Syntactically, your er nested chord request would look like: er:h ← er:j ↓ er:k ↑ er:l → er:e : er:r : er:⎋ : re:h ← re:j ↓ re:k ↑ re:l → re:e : re:r : re:⎋ :

Of course, you don't need to support all exit keys. And the dual er/re chords are because you don't care about order. I could write it as :h instead, but at the moment I'm keeping the format to one chord per line.

Well, there is one more question. You weren't talking about 3-key chords, right? They are supported:

erh ← etc.

Sounds reasonable? It may take a week to get time to implement the trigger generator.

Stephen Simmons

On Sun, Sep 17, 2017 at 9:22 PM, Peter Jaros notifications@github.com wrote:

@stifynsemons https://github.com/stifynsemons It looks like that's for translating chords to words, yes? What I'm trying to do is map a chord to mode, so for instance, [ER] + H/J/K/L is left/down/up/right, and [DF] + H/J/K/L moves between panes within a window. I've been using variables, but it just gets too complicated. I'm actually not certain it's possible to do the chording I want and type normally if I just press the chord characters as part of normal typing and don't hold them to press another key. SimultaneousKeyPresses just did what I wanted perfectly.

(I should say that I'm eternally grateful for Karabiner, and I wouldn't have anything to miss in the first place if it weren't for the hard work that's gone into this amazing project. I fear my previous comment came out a bit entitled. I'm only frustrated because I feel like I've tasted the perfect keyboard setup and Sierra took it all away.) :)

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/tekezo/Karabiner-Elements/issues/153#issuecomment-330122038, or mute the thread https://github.com/notifications/unsubscribe-auth/AAkwmjqZb6l3ZafFyGsjf2b9b0D5MQdHks5sjeHygaJpZM4KGnzp .

stifynsemons commented 7 years ago

Hi Peter,

Initial complex manipuator generator written support mode and chords.

I've written a more general purpose chord-mode generator, and released an alpha version. The normal output is the same, but the extended mode feature is in "output.json"

So, if you manually run:

./chord2json ke.header ke.footer test.chords

you'll get the output file, output.json, which is just the complex manipulators. You can manually insert this into your karabiner.json or use cat ke.header output.json ke.footer > karabiner.json mv karabiner.json .. at least if you have ke.header and ke.footer set up correctly.

This works with the [er] mode, with e or r to exit, but the reverse chord [re] is non-functional because I don't yet support interlocks between mode triggers (I think). There is a lot more to do.

Stephen Simmons

On Mon, Sep 18, 2017 at 8:20 PM, Stephen Simmons stifynsemons@gmail.com wrote:

Hi Peter,

I showed examples chords into words, because you mentioned chords. But I have been playing with nested chords (manually), where an initial chord pair sets a mode, and creates an overlay set of keys (or chords) that take priority over the chords or keys that they replace. I had to manually extend conditions to make the overlays compatible with chords using the trigger chords.

The next step would be add a trigger generator to ke-chording, and to add the interlocks as well.

My remaining question is, how should you leave the mode?

In my hack, I used zx and xz as the nesting triggers, and either z or x would leave whatever nesting had been entered. An alternative would be to leave by ESC or some similar key.

Syntactically, your er nested chord request would look like: er:h ← er:j ↓ er:k ↑ er:l → er:e : er:r : er:⎋ : re:h ← re:j ↓ re:k ↑ re:l → re:e : re:r : re:⎋ :

Of course, you don't need to support all exit keys. And the dual er/re chords are because you don't care about order. I could write it as :h instead, but at the moment I'm keeping the format to one chord per line.

Well, there is one more question. You weren't talking about 3-key chords, right? They are supported:

erh ← etc.

Sounds reasonable? It may take a week to get time to implement the trigger generator.

Stephen Simmons

On Sun, Sep 17, 2017 at 9:22 PM, Peter Jaros notifications@github.com wrote:

@stifynsemons https://github.com/stifynsemons It looks like that's for translating chords to words, yes? What I'm trying to do is map a chord to mode, so for instance, [ER] + H/J/K/L is left/down/up/right, and [DF] + H/J/K/L moves between panes within a window. I've been using variables, but it just gets too complicated. I'm actually not certain it's possible to do the chording I want and type normally if I just press the chord characters as part of normal typing and don't hold them to press another key. SimultaneousKeyPresses just did what I wanted perfectly.

(I should say that I'm eternally grateful for Karabiner, and I wouldn't have anything to miss in the first place if it weren't for the hard work that's gone into this amazing project. I fear my previous comment came out a bit entitled. I'm only frustrated because I feel like I've tasted the perfect keyboard setup and Sierra took it all away.) :)

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/tekezo/Karabiner-Elements/issues/153#issuecomment-330122038, or mute the thread https://github.com/notifications/unsubscribe-auth/AAkwmjqZb6l3ZafFyGsjf2b9b0D5MQdHks5sjeHygaJpZM4KGnzp .

Peeja commented 7 years ago

@stifynsemons That's quite impressive! Thanks!

What I'm actually talking about it holding [ER] while pressing another key. So, it's like a three-key chord, but the ER has to come first. At least, that's how I had it in Karabiner, but maybe it wouldn't hurt to make it work in any order? I'll give it a try.

stifynsemons commented 7 years ago

Thanks; as you can imagine, having by necessity of preserving my fingers to cut total button presses by 50%, losing Karabiner was a big blow. But also an opportunity to re-think how to do things right. To be able to ugrade, I still need to mix these chords and mode with sticky modifiers, and my attempts with modes so far aren't working and I'm not sure why.

To your point, three chord keys are supported, just use things like: erh instead of er:h

They are order specific, which means you have to enter all the order you care about.

Stephen Simmons

On Tue, Sep 26, 2017 at 9:12 AM, Peter Jaros notifications@github.com wrote:

@stifynsemons https://github.com/stifynsemons That's quite impressive! Thanks!

What I'm actually talking about it holding [ER] while pressing another key. So, it's like a three-key chord, but the ER has to come first. At least, that's how I had it in Karabiner, but maybe it wouldn't hurt to make it work in any order? I'll give it a try.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/tekezo/Karabiner-Elements/issues/153#issuecomment-332231212, or mute the thread https://github.com/notifications/unsubscribe-auth/AAkwmjF5tgcmnwO_SpdQKWqz5yCM-Btsks5smRRkgaJpZM4KGnzp .

ramseysparrow commented 6 years ago

Hi @Peeja and @stifynsemons, @watsoncj

Please forgive me for bluntly joining this conversation, but it seems to be related to my issue and contrary to myself you seem to know your code rather well. I'm a writer / film-maker with absolutely ZERO knowledge of coding other than basic writing markdown.

I do write a lot and to top it up I'm also left handed, so Karabiner was to me an absolute blessing and one of the best things that ever happened to my hands when on keyboard. Unfortunately I will soon have to update from el capitan to sierra or further - that means karabiner elements.

Could I please ask your advice. The below is what I currently use; I wonder if I can replicate the same behavior with karabiner elements. It is also worth mentioning that I managed to create my own custom variations in Karabiner by monkey-copying and reverse engineering some custom stuff I found around - which is the extent of my coding knowledge. So the question is really: can I do the same things via custom code with Karabiner Elements?

S+D hold-press to activate simultaneous VI mode for those functions:

JIKL arrow keys.

SD+,
SD+. to jump one word back or forward (replicating standard 'alt+arrow' behaviour)

SD+F to turn backspace into forward delete (F becomes fn key)

CMD + \ to mirror CMD+Tab as an app switcher for a left-hander with: [ to act as W (close window in app switcher mode) ] to act as Q (close app in app switcher mode) CMD+. to mirror CMD+` as a window switcher for a left-hander.

Any advice or help would be much appreciated, it's a terrible shame that karabiner got killed off by sierra update just 4 months after I found out about it.

Thanks in advance! M

stale[bot] commented 6 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.