How do ifGestures work? And Time Machine?

Confused on the two topics. I want to replicate vims cow, diw etc.

I think I can do this by creating a new intermediary layer which only has i as an option otherwise every key changes back a later. But it sounds like gestures or Time Machine can actually check for the next keystroke and hence reduce a layer.

Could I get a few more examples in this to understand the concepts?

But it sounds like gestures or Time Machine can actually check for the next keystroke and hence reduce a layer.

Yes.


Why do the examples in the user guide not suffice?

If you have a macro ifGesture b c d e f write text "we pressed a b c d e f", bind it on your “a” key and press keys a, b, c, d,e, f, the keyboard will write out “we pressed a b c d e f”.

As to vim’s cow, diw, etc., it may be better to have iw, ow, etc realized as separate macros that would just select the thing, and then call these macros from your c, d… macros.

But yes, having a simple trains of

ifGesture i w final tapKeySeq ...
ifGesture o w final tapKeySeq ...
...

will work.

1 Like

I figured out that ifShift, isGesture is not a conditional like

If () {

}
Else {

}

So I was trying to simply these statements when it wasn’t possible. Can we assign the ifShift result to a variable to put it in a conditional?

They are conditionals just like the more conventional form…

Can you simply post what you tried?

I am trying to implement the vim motion ciw which deletes the word your cursor is in. I have:

ifGesture i w tapKeySeq LA-leftArrow SA-rightArrow delete
toggleKeymapLayer QWM base

I noticed that tapKeySequence does not tap the keys that you are in your current layer, for example, I have v binded to a layer where h, j, k, l, w, e, b all extend a selection by holding shift automatically. So I expected the v in a tap sequence to put the command into visual mode, but it actually types a “v”.

I also noticed that I can’t chain the ifGesture command. as I want

ifGesture i w tapKeySeq LA-leftArrow SA-rightArrow delete
ifGesture toggleKeymapLayer QWM base

So I don’t toggle the layer when just pressing c.

It would be nice for easier readability if I could have

ifGesture i w {
 tapKeySeq LA-leftArrow SA-rightArrow delete
 toggleKeymapLayer QWM base
}

is it possible?

I noticed that tapKeySequence does not tap the keys that you are in your current layer

Yes, commands that take SHORTCUT (according to the grammar that is stated in the reference manual) produce scancodes. E.g., tapKey v means “add the corresponding scancode into the usb report”.

If you want to execute a UHK action that is mapped to a physical key, you need the activateKeyPostponed [atLayer LAYERID] [append | prepend] KEYID command.

Yes.

(If it does not work, then let me know, braces are new and there might be some bugs, especially with time machine commands…)

Yup the braces work, I was trying an equivalent with ifShift yesterday and it wasn’t working. I must have been using the wrong syntax.

Appreciate the help, and explaining the difference between scancodes.

Equivalent with ifShift should work too ¯\(ツ)/¯.