[Feature Idea] Leader key (a la Vim) for CopyQ #2892
Replies: 2 comments
-
I'm using the awesome Kmonad to handle my keyboard, and I have just realized that maybe there's a tool to do (or partially do) what I described in here, Kanata. Ref: https://github.com/jtroo/kanata/blob/main/docs/config.adoc#sequences But I don't think Kmonad and Kanata can run side-by-side 😕 And despite Kanata having leader key sequence, the tool seems not very appropriate to cover the use case of inserting text snippets. It's configuration seems not to be meant to handle long texts, nor has a GUI to quickly add snippets from clipboard like CopyQ. It could work to trigger scripts or other programs. Example:
The thing of having all of these available on CopyQ would be a great thing :) |
Beta Was this translation helpful? Give feedback.
-
Further Extending the IdeaHaving groups of leaders, each one activated with a different global shortcut. Would allow having groups of non-clashing sequences (think of it as grouped by topic for example). Totally optional thing, a single group could suffice for most users, but could give great flexibility to others. |
Beta Was this translation helpful? Give feedback.
-
Hi @hluk & everyone!
I have been thinking about something that I think would be a great fit for CopyQ. Maybe something like what I will describe can be done with copyq-commands, but I'm not very familiar with it.
Intro
I find myself pasting many constants repeatedly, whether they are emojis, fixed text snippets, or whatever. To give an example, despite being myself as much keyboard-driven as I can, I'm tired of typing a bunch of keystrokes to write a smiley (🙂), or other frequent emojis.
You see, 3 steps and a bunch of typing. But this thing of emojis is just an example of "typing" constant text or snippets.
The feature
Taking inspiration from Vim's Leader Key, I thought if we could have a kind of leader mode (activated with a global shortcut), that would allow us to type a sequence of characters and immediately paste the corresponding text. I find the leader key concept, a very powerful idea.
This is better understood with an example.
Example
Consider CopyQ's global Leader shortcut:
Ctrl-,
We define in the configuration a series of "leader command" mappings, like:
fp
: 🤦peace
: ✌(-‿-)✌shr
: ¯_(ツ)_/¯gri
: 😃foo
: Any long and repetitive snippet of text you use daily.Given the above,
(what we type ⟹ what is pasted)
Ctrl-,
smi
⟹ 🙂Ctrl-,
peace
⟹ ✌(-‿-)✌Neither Enter key would be necessary, as the first match could trigger paste1.
Extending the idea
The following may sound out-of-scope, but it is very similar/related, and could leverage the same idea and code of the leader key.
Given that this feature of "leader key paste" could be added to CopyQ, beyond pasting text, it could be very nice to have a different2 leader key (or the same), not to paste text, but to run a command. In this way you could trigger a ton of things, programs, commands, scripts directly from the keyboard.
Examples:
<leader>fnw
: Firefox New Window (when Firefox is not focused, of course)<leader>jira
: Open a new browser window with the Jira URL (so you can quickly create a ticket and close, when the Web browser is not focused, of course).I find leader key a powerful idea, possibilities are endless. But I lack a multi-platform tool for this.
Final Thoughts
All of this is 100% keyboard driven. This could help to use mnemonics to quickly trigger an “infinite” number of texts, scripts, and type stuff. No intrusive GUI while inserting texts3, just leverage the CopyQ engine and it's settings interface 🙂
I think that CopyQ would be a great match for this because, to me, CopyQ becomes the perfect keyboard companion, and most importantly, it works on any platform (Linux, macOS, Windows). Even if the config is file-based, you can add your leader mappings to your
dotfiles
Git repo, and your snippets (whatever they are: texts, emojis, commands?) travel with you.Footnotes
Would need thorough design thinking on how to handle partial matches, for example (a) Require
Enter
to trigger; (b) Trigger after a timeout; (c) Do not allow commands that are substrings/superstrings of other commands, e.g.smi
andsmiley
; (d) ... (An option in settings could be used to requireEnter
). ↩The idea of a different shortcut is to allow a different/separate set of mappings. Using a different shortcut could be optional, and could reduce clashes. ↩
This is important, user has no GUI prompt (or maybe an option?), as leader sequence runs behind the scenes and ends on timeout. But leader sequence tend to be completed very fast (short timeout). If no match, nothing pasted. Focus is not lost from the current window. ↩
Beta Was this translation helpful? Give feedback.
All reactions