godbout / kindaVim.docs

Ultimate Vim Mode for macOS
https://kindavim.app
623 stars 4 forks source link

Get out of visual mode without losing highlighted text #151

Closed ericauld closed 1 year ago

ericauld commented 1 year ago

I may be missing it, but is there an easy way to get out of visual mode while keeping the selection?

As a workaround, I could send a command such as cmmd + c (if I don't mind losing the contents of the clipboard).

My use case is for programs (such as Roam) which do auto-surrounding with delimiters of highlighted text. I can highlight the text in visual mode, get out of visual mode, and then press e.g. ( to surround the text.

godbout commented 1 year ago

I may be missing it, but is there an easy way to get out of visual mode while keeping the selection?

the philosophy of kV is to stick to Vim's habits. as far as my research went in Vim you can't leave Visual Mode and keep the selection intact. BUT because kV also integrates with macOS, you can somehow 😀️ with the passthroughs:

Screenshot 2022-12-22 at 14 53 46

if you switch on the passthroughs, any key combination that will contain option and/or command will be let through to macOS, and your Visual Selection will be kept intact. this is useful for stuff like Alfred's Universal Actions where you act on pieces of text.

My use case is for programs (such as Roam) which do auto-surrounding with delimiters of highlighted text. I can highlight the text in visual mode, get out of visual mode, and then press e.g. ( to surround the text.

so what you should probably do is assign a key combination that contain option and/or command to your programs, and use the passthrough. that'd be the kV vanilla/integrated way to do it. there's probably other ways possible too, with tools like Hammerspoon and using kV's Distributed Notifications. you can listen to kV's Mode change, and act accordingly on them:

https://user-images.githubusercontent.com/121373/209081632-95e89b8b-7bb3-4966-bd4a-72b9a4503788.mp4

lemme know if that helps and if i understood your question correctly.

ericauld commented 1 year ago

Yes, that does answer my question. I appreciate your help!

godbout commented 1 year ago

sure. the apps come with heavy support. i (try to) answer daily. mostly i'm abusing the AX APIs which are already pretty funky, so it's quite hard for even an experienced macOS user (i think) to understand what's going on sometimes, and why kV (and the other apps) works the way they do. so i'm always here to answer. please always feel free to shoot!