11
Snippets
Anatolii Hrynchuk edited this page 2026-11-12 01:40:33 +02:00

Snippets — text templates

English | Українська

Desktop chat selection — v0.6.55

Long triggers can fail when an editor processes only some selection key events. ChatGPT and Codex desktop editors now use paced selection. If the copied selection is a verified suffix of the trigger, KSwitcher extends it and checks the complete trigger before replacing anything. A different selection or changed focus cancels the operation. The dedicated Far Manager behavior below is unchanged.

Triggers are recognized across keyboard layouts: typing the same keys in another installed layout can still expand the snippet. This existing behavior is not a new option. One snippet can also be assigned to multiple applications: click Add app for each application, or enter names separated by commas, such as ChatGPT.exe, chrome.exe, ms-teams.exe. Adding another app keeps the previous entries, and the list is saved and synchronized.

If a long trigger remains unexpanded, update to v0.6.55 and retry with focus in the text field. Check the allowed applications and avoid changing focus during expansion. If it still fails, enable Write log, reproduce once and inspect the operation in Logs. Selection and paste verification remain required; the fix does not bypass them or submit unverified text. Existing editor screenshots remain accurate because the controls did not change.

Application-specific snippets — v0.6.51

Existing snippets remain global. Enable Only in these applications (unchecked: everywhere) to restrict a snippet. Enter comma-separated process names such as chrome.exe, ms-teams.exe, or choose a running application and click Add app. You can type a process name for an application that is not running. Names ignore case and the optional .exe suffix; paths and wildcards are not supported. An enabled restriction requires at least one application. Chrome means the entire browser, not one website.

The list shows [All apps] or the selected processes. Save applies edits; Cancel discards them. A matching application-specific snippet takes priority over a global snippet with the same trigger; elsewhere the global snippet remains available. The same trigger is allowed in disjoint application scopes, but overlapping scopes are rejected. The target application is checked again before insertion. No OCR or polling timer is used.

Manual export/import and synchronization preserve application scopes. Update every synchronizing PC to v0.6.51 or newer before sharing restricted snippets: older versions may treat them as global or reject repeated triggers. Keep a backup before downgrading. Sync conflicts distinguish the trigger and its application scope.

Application-specific snippet editor

Open Settings → Tools → Snippets…. A snippet replaces a short trigger with a greeting, signature, repeated reply or checklist. Replacement text can contain multiple lines and a caret-position marker.

  1. Click Add to create an entry, then enter a Trigger, such as ;hello.
  2. Enter Replacement text, including line breaks.
  3. Click Save in the snippets window to apply your changes.
  4. Type the trigger into a text field. Expansion happens when the full trigger is typed; no additional Space is needed.

Select an existing entry to edit it; Delete removes the selected snippet. Triggers are recognized across keyboard layouts, so you do not need to switch language just to invoke one.

Example: ;run → rider .{enter} (insert text and press Enter).

Far Manager snippets — v0.6.45

In Far, :r → rider . now replaces the complete trigger and leaves the cursor after the inserted text. KSwitcher uses Far's Alt+Shift+Arrow selection, Ctrl+Insert copy and Shift+Insert paste, with exact clipboard verification before and after replacement. It restores the complete temporary selection on cancellation instead of moving the caret one character. This works with panels visible or hidden. {cursor} and {enter} actions run only after verified insertion; changed focus, input or clipboard cancels further actions. Other applications retain accessibility verification.

Far replacements must be nonempty, single-line and at most 4096 caret steps. Empty or multiline replacements are rejected before selection: a pasted newline could execute a command before verification. Use an explicit {enter} after a single-line command. Example: :r → rider .{enter}. No trigger or shortcut defaults changed.

See also Utilities and the tools folder.

Examples

;hello

Hello, {cursor}!
Thank you for your message.

;thanks

Thank you for your help!
Best regards,
Demo User

;check

Release checklist
- Build
- Run tests
- Publish

{cursor} is not inserted literally: the caret moves to that marker. In the greeting, it lands after the comma and space, ready for a name. Use {{cursor}} to insert the literal text {cursor}.

Choose distinctive triggers with a prefix such as ; to avoid expanding templates during ordinary typing.

Enter actions and continuous typing

Use {enter} to press Enter after insertion and cursor placement, once for each marker. For example, rider .{enter} inserts rider . and then presses Enter. {{enter}} inserts the literal marker. Enter may submit a message or command in the target application; a line break written in the replacement is plain multiline text instead.

Typing immediately after a trigger is buffered and replayed after expansion. Automatic correction is suppressed for the expansion and its buffered typing; the global setting stays enabled for subsequent input. Since v0.6.17, the trigger/replacement fields, Delete and marker buttons are disabled until an entry is selected or added. Deleting the selected entry clears and disables the editor.

Copy failures (v0.6.19)

Before replacing a trigger, KSwitcher copies and verifies the selected text. If Ctrl+C produces no clipboard change, it can try again, up to three total attempts, provided the active input context and transaction clipboard have not changed. If the trigger still cannot be verified, expansion is cancelled: the trigger remains, queued typing resumes, and no {enter} action is sent. Paste is not blindly retried.

{enter} is a key action, not a promise of a newline: a multiline editor normally inserts a line break, a single-line field may ignore it, and a chat or terminal may submit the text. No snippet syntax, shortcut or default changed in this patch.

Synchronization (v0.6.26)

Snippets retain stable IDs across renames. Independent edits merge; deletion records prevent unchanged offline copies from restoring removed snippets. Deletion versus editing and duplicate triggers are resolved per item under Sync… → Resolve individual conflicts…. Existing snippets migrate automatically; update all PCs for sync format 2. Setup and recovery.

Editor access keys (v0.6.27)

Alt+A adds, Alt+D deletes, Alt+T focuses Trigger, Alt+R focuses Replacement text, Alt+M inserts the cursor marker, Alt+E inserts the Enter marker, Alt+S saves and Alt+C cancels. Disabled actions remain unavailable. See access keys.

Mouse Without Borders and verified snippets — v0.6.43

Update KSwitcher on both PCs, especially the computer sharing its physical keyboard. KSwitcher now lets downstream keyboard hooks route events before processing them and ignores consumed events on the source computer. Delivered remote input still supports shortcuts, recent typing, automatic correction and snippets. An older source-side instance can still start duplicate operations and publish temporary clipboard markers. Closing that instance is a temporary workaround until it is updated.

Outside Far Manager (see the v0.6.45 exception in Snippets), snippets require accessibility verification of the selected trigger and pasted replacement even with Write log disabled. Unavailable initial verification stops expansion before paste. Incorrect or unavailable readback stops subsequent cursor and {enter} actions. Incorrect inserted text can remain for inspection; it is not automatically submitted or blindly replaced again. Buffered typing resumes. Syntax, default settings and shortcuts are unchanged.

Identical clipboard relays are accepted only after target-owned selection contents have been observed, with matching text and editor selection metadata. Unicode allocation padding and format order do not affect comparison. Different contents, missing metadata and unobserved foreign copies remain rejected. Own plain-text replacement payloads also tolerate identical relays. Clipboard changes during paste stop subsequent actions. Before selection, snapshot capture may retry up to three times if the clipboard changes and input context remains unchanged. Restoration does not overwrite unrelated newer clipboard contents.

Click a warning notification to open Logs. Enable Write log for incident details, reproduce once and copy the complete operation. Rejected copies now include the local sentinel, target/current text, owner and sequence numbers. Review captured text before sharing.

Regression tests exercise a real downstream forwarding hook, normal snippet expansion and suppression of Enter after an incorrect paste. Live validation on two computers with both installations updated remains outstanding. Existing screenshots still apply; no control layout changed.