Skip to content

Text expander: edit all shortcuts as one text, plus %tab%, %tabkey% and %enter% - #695

Open
4di-hello wants to merge 2 commits into
LeanBitLab:mainfrom
4di-hello:feature/text-expander-as-text
Open

4di-hello wants to merge 2 commits into
LeanBitLab:mainfrom
4di-hello:feature/text-expander-as-text

Conversation

@4di-hello

Copy link
Copy Markdown
Contributor

I use the text expander a lot for long AI prompts (some are 2,000+ characters). Two things made that hard: the template field is small and fixed-height, and moving shortcuts between devices or editing them on a PC is only possible via a full backup. This PR adds both without any new settings.

Edit all as text

A button "Edit all as text" on the Text expander screen opens all shortcuts in one full screen editor:

=== ;cic ===
Long prompt …
over several lines

=== mfg ===
Best regards
  • Copy all / Paste all, Share, Save as file, Load from file – easy to edit in any editor and move between devices
  • Jump bar with all shortcuts, tap to jump to a block
  • Saving applies exactly the text: first it checks for errors (with line numbers: duplicate shortcut, space in shortcut, empty text, invalid regex, text before the first header), then it asks for confirmation showing "x new, y changed, z deleted" and lists deleted shortcuts by name
  • Restore previous: the state before the last save is kept and can be restored (tapping again switches back)
  • Prefixes are kept (characters before the first letter, e.g. ;cic), regex shortcuts are written as === regex: pattern ===
  • Header lines are highlighted, the existing placeholder chips are available in the editor too

New placeholders

  • %tab% inserts a tab character (indentation, tables)
  • %tabkey% presses the Tab key, e.g. to move to the next form field
  • %enter% presses Enter, i.e. the editor action (send, search, next) or a plain Enter key if the field has none

With %tabkey% / %enter%, text parts and key presses are sent one after another with a 150 ms pause after each key press, so the app can move focus first. Cursor placeholders are ignored in that case. Without these placeholders, nothing changes.

Code

  • TextExpanderText (new): formatting, parsing, diff – plain Kotlin, covered by TextExpanderTextTest (8 tests)
  • TextExpanderTextEditor (new): the editor screen
  • TextExpanderScreen: button + the placeholder chip row moved into a reusable composable (no behavior change)
  • TextExpanderUtils.expand: %tab%
  • InputLogic.commitExpandedText: key press placeholders, the existing path is unchanged when they are not used
  • No new settings, no changes to how shortcuts are stored

Tests

  • TextExpanderTextTest 8/8, InputLogicTest 125 (1 skipped), SuggestionStripLayoutHelperTest 4/4 – all pass on current main
  • Tested on my device with about 40 shortcuts, including several long prompts

4di-hello and others added 2 commits October 19, 2026 02:21
Long templates such as prompts are hard to edit in the small field, and
shortcuts can only be moved between devices with a full backup.

"Edit all as text" (Text expander screen) opens all shortcuts in one
full screen editor, each starting with a line "=== shortcut ===":
- copy all, paste all, share, save to and load from a text file
- a jump bar with all shortcuts
- saving applies exactly the text, after checking for errors (with line
  numbers) and confirming new, changed and deleted shortcuts
- the state before the last save can be restored
Prefixes are kept (characters before the first letter, e.g. ";cic"),
regex shortcuts are written as "regex: pattern".

New placeholders: %tab% inserts a tab character, %tabkey% presses the
tab key (next field), %enter% presses enter (the editor action, e.g.
send). With key presses, text and keys are sent one after another with
a short pause, so the app can move to the next field first.

No new settings. The parsing is covered by TextExpanderTextTest.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VuiaMhLXwhErf9shhrr1uD
…text

Key press placeholders (%enter%, %tabkey%) were looked for in the fully
expanded text. Text from the clipboard (%clipboard%) containing "%enter%"
could therefore press enter, e.g. send a message too early.

Now the placeholders are replaced by internal markers in the template,
before anything is inserted, and markers are removed from clipboard text.
Regex shortcuts are skipped if the text before the cursor contains a marker.

The remaining steps of an expansion with key presses are dropped if
another app gets the focus in the meantime, or a new expansion starts,
so the rest is never typed into another app.

Tests in TextExpanderUtilsTest.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VuiaMhLXwhErf9shhrr1uD
@4di-hello
4di-hello force-pushed the feature/text-expander-as-text branch from a942d6e to b548297 Compare October 19, 2026 05:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant