A general dynamic text snippet functionality

I would like to be able to insert the current time or date (in my format choice/preference) or any self-defined text (phone number, company name, credit card number, …) by using some keyboard shortcut and an identifier. (Debian GNU/Linux 13 with Plasma 6 switching between X11 and Wayland because of Wayland instabilities in combination with my TB dock - different topic)

While using xfce/X11, there were plenty of options for getting text snippet expansion. My choice for many years was AutoKey. With Wayland, most options are dead now.

Kate has Snippets but in my opinion, this type of functionality needs to be available on OS level for all apps and not just for one application.

I tried a bunch of DIY approaches with tools like dotool/wlrctl/wtype/ydotool with klipper/wayclip/wl-clipboard and kdialog/qarma/yad/zentiy/dialog but failed so far. It seems like Plasma 6 Wayland does have an issue with some tools. I could post details on all of them.

I even tried Espanso which seems to work for many people. It just did not work on my machine: I could make it run somewhat for some applications (like GNU Emacs where I do have my own snippet expansion system anyway) but not for any arbitrary application.

I think that this is one of the functionality I would expect KDE to provide for me. Maybe built-in to Klipper, maybe with its own application. This way, users do not need to fail with all sorts of DIY solutions (like I did) or stick to external tools like Espanso which doesn’t work here as well.

AutoKey defined general abbreviations which were captured while being typed. This way, I had $$dd for 2026-03-23 (today) and $$tt for 2026-03-23T11.53 (now in adapted ISO 8601 because of issues with colons in file names) and $$cc for my credit card number. I can think of one system-wide keyboard shortcut which opens a query dialog in order to complete defined snippets. Both would be fine with me.

I wonder why this is not a discussion topic I could find here.

Edit: I had to remove all URLs (although the WYSIWYG-editor provides them as syntax element) because I’m not allowed to use URLs here. For whatever reason.

1 Like

Just brainstorming here: this sounds like a use case for an Input Method Editor.

Traditionally used to compose (East) Asian language characters by typing a series of latin characters.

In this case the series of latin characters would be the snippet ID and the replacement would be the expanded text.

However, this also reminds me of discussions here about KCharSelect and emoji selector being able to “type” into applications instead of using copy&paste.

Whatever the solution is for those will be, it could potentially also work here.

1 Like

perhaps the new “long press to select” feature will let us configure more than just individual characters but entire stings of characters under each key cap.

1 Like

I was also considering Plasma Keyboard as a potential entry/extension point as it inherently can already send keyboard input to any application.

The idea of using the long-press as a trigger didn’t occur to me though however that does sound neat.

E.g. maybe long press on | could allow running a command and sending its output to the currently active input field.

Not sure how feasible this is as the UI would be more complex than the “choose one out of a small number of alternative characters”. Maybe @Merritt has any thoughts on that :slight_smile:

2 Likes

We’ve been cooking up the idea for this feature for Plasma Keyboard. I laid a lot of the difficult groundwork for it with the recent long-press diacritics feature, so it will be easier to implement now.

I created an issue with my current thoughts: Text Expansion (#72) · Issues · Plasma / Plasma Keyboard · GitLab

None of the details have been decided yet, we need to do some research and brainstorming to figure out the best features and UX.

2 Likes

This’ll be due to the Discourse forum’s trust levels: Understanding Discourse Trust Levels

Basically once you’ve participated a bit more those restrictions fall away.

1 Like

could this be a part of the long-press feature where—in addition to accessing larger character choices—you could also access pre-filled strings?

i can imagine once the feature is triggered, the pop-up shows all the character options available as well as one pre-filled text option for each key cap… these would need to be editable in settings somehow.

also, “long-press” is a bit too virtual keyboard specific if this feature is going to be available on hardware keyboards—to avoid the repeat key conflict.

I’m no expert here but I do have a QMK keyboard with some keys using different mapping if long-press is involved or act as modifier keys if long-pressed (keyword: home modifier keys). Your suggestions sound like that could be a potential conflict here for those (rare) cases.

This sounds like a messy UI, but also kind of unnecessary.

If you have text expansion available and prefix all your triggers with : for example, then typing : and a character acts the same way if an overlay pops up to show matching text expansions that have been configured.

For example: my text expansions include among them :email, :eli, and :elephant. I type :e and get an overlay showing those 3 items → I keep typing :el and now it shows only :eli and :elephant:elephant is the preselected choice, so I press Tab to accept and now :el has been replaced with Did you know that elephants are one of the only non-human animals that recognize themselves in a mirror‽ You've been subscribed to elephant facts!

Crucially, such a list of options would be a vertical list rather than horizontal (the way the diacritics options are), which would fit much better with a longer string like that compared to the single characters for diacritics and accents — and :e isn’t meaningfully more difficult than long-pressing e, while keeping the features more distinct.

I’ve never come across the burning need to enter huge long sequences of the same character, but if I really just had to say “ohhhhhhhhhhhhhhhhhhhhhhhhhh” instead of “ohh”, I could tap it out or copy 2-3 of them and just paste repeatedly for that rare scenario.

Key repeat like that seems more like spacebar heating than anything meaningfully useful.

2 Likes

going with your example of text expansion—you would have a trigger character (say : ) that activates a new GUI to offer choices based on what comes next (ala the meta+v clipboard menu)

in your example you would need to type : followed by both e and then l to get the menu winnowed down to elephant being the default entry and then you still need to hit tab for the text to be entered into the application.

fair enough, but what about the more common use case of just needing to type a : followed by another letter?… i don’t want to be fending off an unwanted GUI every time i a use a colon in a sentence.

as an alternative, what if when the “long-press” is triggered, it would show you the (horizontal) list of 6 variants and a 7th option that is your per-configured string for that key.

with “long-press” i would need only to hold the e key until the pop up menu is triggered and then hit 7 to get all the elephant facts.

even if i have “long-press” set to activate using the AltGr key, i would still only need to enter AltGr+e to trigger the menu, and then hit 7 to get all the facts inserted.

maybe, but you will have Meddled With the Primal Forces of Nature if you change how key repeat works.

there should at least be options to set other keys to be the trigger, such as using AltGr as a modifier, or activating the mode using the Compose key… and i would argue that next to the settings for key repeat delay and rate, there would be the option to override with long-press features instead.

1 Like

The colon : is used for entering mac addresses, and sometimes ip addresses, that would be a really bad idea as a modifier.

We need to look at a range of keyboard layouts and find a combination that is esoteric enough not to clash with most applications, but is also present on the vast arrays of keyboards out there. I happen to use several Logitech keyboards and bemoan the missing printscreen key on most of them. May I humbly suggest the esc key with modifiers? Every keyboard has the escape key and some of the various squiggles that are printed on the modified key are very rarely used. For instance who has ever used the ¬ symbol? That’s just shift-esc (at least on Logitech keyboards…)

the AltGr key is what i would suggest

it can be assigned to a number of different keys in the Advanced tab of keyboard settings.

the compose key is (and likely should be) another option

the compose key location can also be set to a number of different keys in the settings.

As long as it’s an esoteric rarely used. I have no idea what a “compose” or “altgr” key is/are but they sound suspiciously Apple-like to me. I have never seen either of those on a standard keyboard. Are there any other designations/labels for those keys?

Just looked up compose key- Compose key - Gentoo Wiki

Gentoo Wiki

wiki › Compose_key

6 Oct 2023 — The Compose key, also known as Multi_key on the X Window System, allows one to combine several keys into one character Contents.

and this too:- AltGr key

Wikipedia

wiki › AltGr_key

AltGr (also Alt Graph) is a modifier key found on computer keyboards. It is primarily used to type characters that are used less frequently in the language

It still does not say whereabouts on the keyboard it may be except for the right alt key but no modifier.

That might depend on the layout.

On a German keyboard it is usually the next key on the right hand side of the space bar.

For example @ is the result of AtlGr + q

Normally if you buy a keyboard in a place whose common layouts use AltGr, the relevant key has “AltGr” printed on it.

e.g. a Logitech UK keyboard - compare the legends between the keys on the left- and right-hand side of the space bar.

If you have a US keyboard, it’ll be the right Alt.

I really should put my glasses on - never noticed it before! Silly old fart sometimes.

they are not labeled because they can be assigned to existing keys in settings > input devices >keyboard > advanced

i have AltGr (also called the 3rd level shift key) set to my right Alt key (the left Alt still works as Alt).

i have the Compose key set to my right Ctrl key (the left Ctrl key still works as Ctrl).

these two functions allow access to a far greater number of characters than what is printed on the keycaps of the standard 104 key keyboard.