opencode icon indicating copy to clipboard operation
opencode copied to clipboard

Add configurable readline-style text transformations to TUI prompt

Open aspiers opened this issue 1 day ago • 1 comments

Feature hasn't been suggested before.

  • [x] I have verified this feature I'm about to request hasn't been suggested before.

Describe the enhancement you want to request

Summary

Add configurable Emacs/readline-style text editing shortcuts to the TUI (terminal) prompt input to improve text editing efficiency and provide power users with familiar keybindings.

Problem Statement

Currently, users working in the terminal UI must manually retype text to perform common text editing operations such as:

  • Changing word case (uppercase, lowercase, capitalize)
  • Pasting previously deleted text
  • Transposing characters

This slows down text editing workflows and prevents users from customizing keybindings to match their preferred editor shortcuts (particularly Emacs/readline style).

Desired Features

The following text transformation operations should be available as configurable keybindings:

Case Transformations

  • Uppercase word - Convert word from cursor position to uppercase
  • Lowercase word - Convert word from cursor position to lowercase
  • Capitalize word - Capitalize word from cursor position

Kill Ring / Paste Buffer

  • Yank - Paste the last deleted text at cursor position
  • Support for storing deleted text from existing delete operations (ctrl+k, ctrl+u, ctrl+w, alt+d)

Character Manipulation

  • Transpose characters - Swap character under cursor with previous character

Expected Behavior

All new shortcuts should be fully configurable via opencode.json keybindings configuration, allowing users to customize or disable them as needed. Default bindings should not conflict with existing TUI functionality.

Example Configuration

{
  "keybinds": {
    "input_lowercase_word": "alt+l",
    "input_uppercase_word": "alt+u",
    "input_capitalize_word": "alt+c",
    "input_yank": "ctrl+y",
    "input_transpose_characters": "ctrl+t"
  }
}

Implementation Notes

  • Word boundary detection should follow readline/Emacs behavior
  • Case transformations should respect word boundaries
  • Kill buffer could start as a simple single-entry buffer with future expansion to a full kill ring
  • Tests should verify word boundary detection and transformation functions

aspiers avatar Jan 18 '26 10:01 aspiers