Open dbalatero opened 2 years ago
hmm. that only happens on the last word of a text. in any app that uses the Keyboard Strategy
:
https://user-images.githubusercontent.com/121373/192167152-3d009e5e-7826-43b7-80a5-52b7526cd233.mp4
the reason is because the key mapping for dw
is:
this simulates a dw
well, except on the last word, the option shift left
cancelling the second option shift right
. so that mean i'd need to find a better mapping that works in all cases, but i'm not sure whether something exists that covers every case. one way could be to make dw
work like cw
but stay in Normal Mode
. that would somehow work on the last word, but that wouldn't be exactly like the real Vim dw
, as it wouldn't delete the spaces after a word.
one way could be to make dw work like cw but stay in Normal Mode. that would somehow work on the last word, but that wouldn't be exactly like the real Vim dw, as it wouldn't delete the spaces after a word.
Yeah, this is the trade-off I made here:
https://github.com/dbalatero/VimMode.spoon/blob/master/lib/motions/word.lua#L88-L96
Another option is maybe if you had enough of the AX API available, you could detect if you were at the end of the input/at the last word and modify slightly the strategy? (I don't think I ever got this to work well, but…)
Another weird thought I've always had is around that DefaultKeyBindings.dict
file. Is there a world in which kindaVim could install some custom bindings and use those to fire some additional extended key mappings?
https://ss64.com/osx/syntax-keybindings.html
I see all these events that can be fired:
/* Remap Home / End keys to the start/end of paragraph (or line) */
"\UF729" = moveToBeginningOfParagraph:; // Home
/* or "\UF729" = "moveToBeginningOfLine:"; */
"\UF72B" = moveToEndOfParagraph:; // End
/* or "\UF72B" = "moveToEndOfLine:"; */
"$\UF729" = moveToBeginningOfParagraphAndModifySelection:; // Shift + Home
/* or "$\UF729" = "moveToBeginningOfLineAndModifySelection:"; */
"$\UF72B" = moveToEndOfParagraphAndModifySelection:; // Shift + End
/* or "$\UF72B" = "moveToEndOfLineAndModifySelection:"; */
/* Remap keys for Start/End of document */
"^\UF729" = moveToBeginningOfDocument:; // Ctrl + Home
"^," = moveToBeginningOfDocument:; // Ctrl +,
"^\UF72B" = moveToEndOfDocument:; // Ctrl + End
"^." = moveToEndOfDocument:; // Ctrl +.
"^$\UF729" = moveToBeginningOfDocumentAndModifySelection:; // Ctrl + Shift + Home
"^$\UF72B" = moveToEndOfDocumentAndModifySelection:; // Ctrl + Shift + End
/* Remap keys for switching the case of the current word */
"~-" = lowercaseWord:;
"~=" = uppercaseWord:;
"~." = capitalizeWord:;
I'm curious if there are a ton of hidden, useful events that could be abused by kindaVim to get even more Vim-like functionality out of the keyboard strategy?
For example, if we can find a moveToBeginningOfNextWord
event, that would help fix this dw
case…
(Also can you fire these from Cocoa/Swift directly without "binding" them to a key and potentially conflicting with user key bindings?)
Another option is maybe if you had enough of the AX API available, you could detect if you were at the end of the input/at the last word and modify slightly the strategy? (I don't think I ever got this to work well, but…)
the reason why the Keyboard Strategy
is needed with stuff like Slack, Signal and a lots of Electron apps is exactly because we can't use the AX. they return wrong data, so you can never trust where you are in the text etc. ☹️
I'm curious if there are a ton of hidden, useful events that could be abused by kindaVim to get even more Vim-like functionality out of the keyboard strategy?
i've checked this before going for the current Keyboard Strategy
. i haven't checked for any private APIs, but for the public ones there they are: https://developer.apple.com/documentation/appkit/nsstandardkeybindingresponding
basically what you get is the standard macOS keyboard shortcuts: https://support.apple.com/en-us/HT201236 what you can do is change mappings, but AFAIK, there's no way to have other types of "moves".
seems like the best option is to use D
rather than dw
when at the last word of a text 😅️
but yeah, unfortunately the Keyboard Strategy
is approximative. for the Accessibility Strategy
i strive to make moves exactly as they behave in Vim, as we have access to most of the information we need. but for the KS
, there's so much we can do.
the reason why the Keyboard Strategy is needed with stuff like Slack, Signal and a lots of Electron apps is exactly because we can't use the AX. they return wrong data, so you can never trust where you are in the text etc. ☹️
Yes. I seem to remember from past experimenets that Electron would return selection position, and text value, but not let you set the position or manage the cursor. Is that not what you've found in recent testing?
Yes. I seem to remember from past experimenets that Electron would return selection position, and text value, but not let you set the position or manage the cursor. Is that not what you've found in recent testing?
it's way more shitty than this lol
for Electron apps it depends 1) on the version of the Electron framework they use 2) how they implemented it and/or the AX. that's why i need to curate every single app. some Electron apps actually work very well—strangely, small indie devs like Rambox, Local, apps like Bitwarden—while most others don't, but in different ways.
i think it's almost always possible to grab the whole text, yes. but that's about it. in my last tests with Slack (a few months ago), Slack was mixing selection with line numbers. like if you're anywhere on the second line, it will return 0, 2
(0 for caret location, 2 for selection length). you're at the end of the third line? 0, 3
. i think it's the only one that does this specifically, but most others also implement the AX stuff poorly, and you can't get a proper caret location and selection length.
i think i read that this might also be due to some private API that is needed to make the AX stuff work correctly on Electron but then you can't push your app on the App Store?
but anyways. conclusion: lots of pain dealing with this.
but you're reminding me i may have to go through the App Catalog from time to time and retest each of those Electron apps to see if they've been doing some improvements over time... :CRY_IN_JAVASCRIPT:
seems like the best option is to use D rather than dw when at the last word of a text 😅️
I would get more feedback on this from others, but as a user I would prefer to not have to cognitively remember "oh yeah when it's one word dw
is broken and I have to switch". I think personally I would be fine if the behavior was slightly different but consistent – that is something I can learn and adjust to much easier than doing special casing. Having to do the special casing in my head takes me out of flow, if that makes sense.
I think it's admirable to try to map Vim 1:1, but for this fallback mode I'd ask "is it worth it"?
I would get more feedback on this from others, but as a user I would prefer to not have to cognitively remember "oh yeah when it's one word
dw
is broken and I have to switch".
very fair, and i totally agree.
I think it's admirable to try to map Vim 1:1, but for this fallback mode I'd ask "is it worth it"?
the issue i have is not the 1:1 mapping to Vim. the issue i have is that with kV Accessibility Strategy, dw
is gonna act like the Vim dw
. but not with kV Keyboard Strategy. i don't like this discrepancy. this plus the fact that basically dw
is gonna work all the time except for ONE CASE, which is when you're using it at the end of a text. now your point is also very fair and made me realize that this may actually happen often in text messages apps. so i take this seriously, but digestion is still occurring. i'm not sure yet what's the best way, and i'm not sure making dw
act like cw
is good.
btw, out of curiosity, do you use dw
often? personally i never do. it's harder for me to type in the middle of a word rather than the whole word itself, so i'm a fan of ciw
diw
/daw
.
I am running kindaVim 41, and using desktop Slack.
Attached is a movie of me trying to delete a word with
dw
- as you can see it just deletes backwards one character.Here is my Families config right now:
And other preferences:
https://user-images.githubusercontent.com/59429/192151739-226fbe63-12cc-4f0d-9f0a-09b5c77b996c.mov