par-term 0.49.0

Cross-platform GPU-accelerated terminal emulator with inline graphics support (Sixel, iTerm2, Kitty)
# Paste Special

par-term's Paste Special feature allows you to transform clipboard content before pasting, with 29 different transformations across 5 categories. A configurable paste delay option is also available for slow terminals or remote connections.

## Table of Contents
- [Overview]#overview
- [Opening Paste Special]#opening-paste-special
- [Transformations]#transformations
  - [Shell Category]#shell-category
  - [Case Category]#case-category
  - [Newline Category]#newline-category
  - [Whitespace Category]#whitespace-category
  - [Encoding Category]#encoding-category
- [Paste Delay]#paste-delay
- [Using the UI]#using-the-ui
- [Related Documentation]#related-documentation

## Overview

Paste Special provides a searchable list of transformations with live preview:

```mermaid
graph TD
    Clipboard[Clipboard Content]
    UI[Paste Special UI]
    Search[Search Filter]
    Transform[Transformation]
    Preview[Live Preview]
    Terminal[Terminal]

    Clipboard --> UI
    UI --> Search
    Search --> Transform
    Transform --> Preview
    Preview -->|Apply| Terminal

    class Clipboard external
    class UI primary
    class Search active
    class Transform data
    class Preview external
    class Terminal database

    classDef primary fill:#e65100,stroke:#ff9800,stroke-width:3px,color:#ffffff
    classDef active fill:#1b5e20,stroke:#4caf50,stroke-width:2px,color:#ffffff
    classDef data fill:#0d47a1,stroke:#2196f3,stroke-width:2px,color:#ffffff
    classDef database fill:#1a237e,stroke:#3f51b5,stroke-width:2px,color:#ffffff
    classDef external fill:#4a148c,stroke:#9c27b0,stroke-width:2px,color:#ffffff
    classDef neutral fill:#37474f,stroke:#78909c,stroke-width:2px,color:#ffffff
```

## Opening Paste Special

**Keyboard Shortcut:** `Cmd+Shift+V` (macOS) or `Ctrl+Alt+V` (Windows/Linux)

**Menu:** Edit > Paste Special...

**Alternative:** From Clipboard History (`Cmd+Shift+H` on macOS, `Ctrl+Shift+H` on Windows/Linux), press `Shift+Enter` on an entry.

## Transformations

### Shell Category

| Transform | Description | Example |
|-----------|-------------|---------|
| **Shell: Single Quotes** | Wrap in single quotes, escape internal quotes | `hello world` → `'hello world'` |
| **Shell: Double Quotes** | Wrap in double quotes, escape special chars | `$PATH` → `"\$PATH"` |
| **Shell: Backslash Escape** | Escape shell special characters | `hello world` → `hello\ world` |

**Backslash escaping handles:**
- Spaces, tabs, newlines
- Quotes (single, double, backtick)
- Variable expansion and history (`$`, `!`)
- Shell operators (`&`, `|`, `;`)
- Grouping (`(`, `)`, `{`, `}`, `[`, `]`)
- Redirections (`<`, `>`)
- Glob patterns (`*`, `?`)
- Other specials (`\`, `#`, `~`, `^`)

**Double quotes escape** only `$`, `` ` ``, `\`, `"`, and `!`. **Single quotes** rewrite an internal `'` as `'\''`.

### Case Category

| Transform | Description | Example |
|-----------|-------------|---------|
| **Case: UPPERCASE** | All characters uppercase | `hello world` → `HELLO WORLD` |
| **Case: lowercase** | All characters lowercase | `HELLO WORLD` → `hello world` |
| **Case: Title Case** | First letter of each word | `hello world` → `Hello World` |
| **Case: camelCase** | First word lower, rest capitalized | `hello world` → `helloWorld` |
| **Case: PascalCase** | All words capitalized | `hello world` → `HelloWorld` |
| **Case: snake_case** | Lowercase with underscores | `Hello World` → `hello_world` |
| **Case: SCREAMING_SNAKE** | Uppercase with underscores | `hello world` → `HELLO_WORLD` |
| **Case: kebab-case** | Lowercase with hyphens | `Hello World` → `hello-world` |

**Word boundary detection:**
- Whitespace
- Hyphens and underscores
- camelCase transitions (lowercase to uppercase)

### Newline Category

| Transform | Description | Example |
|-----------|-------------|---------|
| **Newline: Paste as Single Line** | Strip all newlines and join with spaces | `hello\nworld` → `hello world` |
| **Newline: Add Newlines** | Ensure text ends with a newline after each line | `hello\nworld` → `hello\nworld\n` |
| **Newline: Remove Newlines** | Remove all newline characters | `hello\nworld` → `helloworld` |

**Use Cases:**
- **Single Line**: Paste multi-line content as one line (e.g., pasting a path that got line-wrapped)
- **Add Newlines**: Ensure commands are executed when pasted line by line
- **Remove Newlines**: Clean up content with unwanted line breaks

### Whitespace Category

| Transform | Description | Example |
|-----------|-------------|---------|
| **Whitespace: Trim** | Remove leading/trailing whitespace | `  hello  ` → `hello` |
| **Whitespace: Trim Lines** | Trim each line | `  hello  \n  world  ` → `hello\nworld` |
| **Whitespace: Collapse Spaces** | Multiple spaces → single | `hello    world` → `hello world` |
| **Whitespace: Tabs to Spaces** | Convert tabs to 4 spaces | `\t` → `    ` |
| **Whitespace: Spaces to Tabs** | Convert 4 spaces to tabs | `    ` → `\t` |
| **Whitespace: Remove Empty Lines** | Delete blank lines | Removes empty lines |
| **Whitespace: Normalize Line Endings** | Convert to LF | `\r\n` → `\n` |

### Encoding Category

| Transform | Description | Example |
|-----------|-------------|---------|
| **Encode: Base64** | Encode as Base64 | `hello` → `aGVsbG8=` |
| **Decode: Base64** | Decode Base64 | `aGVsbG8=` → `hello` |
| **Encode: URL** | Percent-encode | `hello world` → `hello%20world` |
| **Decode: URL** | Decode percent-encoding | `hello%20world` → `hello world` |
| **Encode: Hex** | Encode as hexadecimal | `AB` → `4142` |
| **Decode: Hex** | Decode hexadecimal | `4142` → `AB` |
| **Encode: JSON Escape** | Escape for JSON string | `"hello"` → `\"hello\"` |
| **Decode: JSON Unescape** | Unescape JSON | `\"hello\"` → `"hello"` |

**Error Handling:**
- Invalid Base64: Shows error message
- Invalid hex: Shows error message
- Invalid URL encoding: Shows error message
- Odd-length hex: Shows error message
- Malformed JSON `\u` escapes: Shows error message (other unknown escapes are preserved as-is)

When the selected transformation fails, the preview shows the error in red and `Enter` does nothing, so the dialog stays open.

## Paste Delay

For slow terminals or remote connections that cannot handle rapid paste, a configurable delay can be added between pasted lines. The delay applies to local panes and to par-mux daemon panes; bracketed-paste markers still wrap the whole paste.

**Config option:** `paste_delay_ms` (0-500ms, default: 0)

```yaml
paste_delay_ms: 50  # Add 50ms delay between pasted lines
```

**Settings UI:** Settings > General > Selection & Clipboard > Paste Delay slider

**When to use:**
- Remote SSH sessions with slow connections
- Serial terminal connections
- Applications that process input line-by-line with buffering limitations

## Using the UI

### UI Layout

```mermaid
graph TB
    subgraph Window["Paste Special Window"]
        Search["Search transformations: [_____________]"]
        Transforms["Transformations List<br/>Shell: Single Quotes<br/>Shell: Double Quotes<br/>..."]
        Preview["Preview Panel (below the list)<br/>Original: [content]<br/>Result: [transformed]<br/>N chars"]
        Hints["Footer: Enter apply, Esc close"]
    end

    Search --> Transforms
    Transforms --> Preview
    Preview --> Hints

    class Window neutral
    class Search neutral
    class Transforms data
    class Preview external
    class Hints neutral

    classDef primary fill:#e65100,stroke:#ff9800,stroke-width:3px,color:#ffffff
    classDef active fill:#1b5e20,stroke:#4caf50,stroke-width:2px,color:#ffffff
    classDef data fill:#0d47a1,stroke:#2196f3,stroke-width:2px,color:#ffffff
    classDef external fill:#4a148c,stroke:#9c27b0,stroke-width:2px,color:#ffffff
    classDef neutral fill:#37474f,stroke:#78909c,stroke-width:2px,color:#ffffff
```

### Navigation

| Key | Action |
|-----|--------|
| `↑` / `↓` | Navigate transformations |
| `PageUp` / `PageDown` | Move a page at a time |
| `Home` / `End` | Jump to first / last |
| `Enter` or click | Apply and paste |
| `Escape` | Cancel |
| Type | Filter transformations |

### Search/Filter

Type in the search box to filter transformations by case-insensitive substring match on the name:
- `base64` → Shows Base64 transforms
- `shell` → Shows shell escaping
- `upper` → Shows uppercase transform
- `case` → Shows all case transforms

### Preview

The panel below the list shows:
- **Original:** First 100 characters of clipboard content (newlines and tabs shown as visible marker glyphs)
- **Result:** Transformed content (first 100 characters) or error message
- **Content length:** Size of the clipboard content in `chars`

## Related Documentation

- [KEYBOARD_SHORTCUTS.md]../guides/KEYBOARD_SHORTCUTS.md - All keyboard shortcuts
- [CONFIG_REFERENCE.md]../CONFIG_REFERENCE.md - Configuration options including `paste_delay_ms`
- [MOUSE_FEATURES.md]MOUSE_FEATURES.md - Mouse-based copy/paste operations