> ## Documentation Index
> Fetch the complete documentation index at: https://mintlify.com/sinelaw/fresh/llms.txt
> Use this file to discover all available pages before exploring further.

# Editing Features

> Comprehensive guide to Fresh's powerful editing capabilities including multi-cursor, block selection, smart editing, and more

Fresh brings IDE-level editing features to the terminal with zero configuration. This guide covers all the editing capabilities available out of the box.

<Note>
  Some keybindings may not work or may differ on your system due to differences in keyboard layouts, terminal emulators, and operating systems. If a keybinding doesn't work, check the command palette (`Ctrl+P`) for alternative bindings, or see the [Keyboard Configuration](/configuration/keyboard) guide to customize them.
</Note>

## Smart Editing

Fresh includes intelligent editing behaviors that adapt to your code:

<CardGroup cols={2}>
  <Card title="Smart Home" icon="house">
    The **Home** key toggles between the first non-whitespace character and column 0, making navigation more efficient.
  </Card>

  <Card title="Smart Backspace" icon="delete-left">
    **Backspace** in leading whitespace removes one indent level instead of a single character.
  </Card>

  <Card title="Auto-indent" icon="indent">
    **Enter** preserves the current indentation level. After `{`, `(`, or `:`, an extra indent level is automatically added.
  </Card>

  <Card title="Bracket Matching" icon="brackets-curly">
    Matching brackets are highlighted automatically. Use "Go to Matching Bracket" from the command palette to jump between them.
  </Card>
</CardGroup>

<Tip>
  Bracket matching is enabled by default. You can toggle it via the `highlight_matching_brackets` setting in your config.
</Tip>

## Undo and Redo

Fresh provides robust undo/redo functionality that intelligently handles multi-cursor edits:

| Shortcut | Action                  |
| -------- | ----------------------- |
| `Ctrl+Z` | Undo last change        |
| `Ctrl+Y` | Redo last undone change |

<Note>
  **Atomic Multi-cursor Operations**: All edits made with multiple cursors are treated as a single atomic operation. One undo restores all cursor positions and their changes simultaneously.
</Note>

### Smart Undo Behavior

Fresh's undo system skips over readonly actions (like cursor movements) and only undos write actions:

<Steps>
  <Step title="Type characters">
    Type `abc` in the editor
  </Step>

  <Step title="Move cursor">
    Move the cursor with arrow keys (readonly action)
  </Step>

  <Step title="Undo">
    Press `Ctrl+Z` — this undos both the cursor movement AND the last typed character
  </Step>
</Steps>

This means you never need multiple undo operations to get back to your actual edits.

## Multi-Cursor Editing

Edit multiple locations simultaneously with Fresh's powerful multi-cursor support. This is one of Fresh's most powerful features, working exactly like VS Code or Sublime Text.

### Creating Multiple Cursors

| Shortcut     | Action                                     |
| ------------ | ------------------------------------------ |
| `Ctrl+D`     | Add cursor at next occurrence of selection |
| `Ctrl+Alt+↑` | Add cursor above current position          |
| `Ctrl+Alt+↓` | Add cursor below current position          |
| `Esc`        | Remove all secondary cursors               |

<Tip>
  When you press `Ctrl+D` with no selection, Fresh automatically selects the word under the cursor first, then adds a cursor at the next occurrence.
</Tip>

### Multi-Cursor Workflow Example

<Steps>
  <Step title="Select a word">
    Position your cursor on a variable name like `value`
  </Step>

  <Step title="Add cursors at matches">
    Press `Ctrl+D` repeatedly to add cursors at each occurrence of `value`
  </Step>

  <Step title="Edit simultaneously">
    Type to replace all occurrences at once, or use arrow keys to move all cursors together
  </Step>

  <Step title="Clear cursors">
    Press `Esc` to return to a single cursor
  </Step>
</Steps>

<Note>
  All multi-cursor edits (typing, deleting, pasting) are atomic — they can be undone with a single `Ctrl+Z`.
</Note>

## Block Selection

Block selection (also called column selection or rectangular selection) lets you select and edit a rectangular region of text across multiple lines.

### Block Selection Controls

| Shortcut      | Action                          |
| ------------- | ------------------------------- |
| `Alt+Shift+↑` | Extend block selection upward   |
| `Alt+Shift+↓` | Extend block selection downward |
| `Alt+Shift+←` | Extend block selection left     |
| `Alt+Shift+→` | Extend block selection right    |
| `Esc`         | Clear block selection           |

### How Block Selection Works

<Steps>
  <Step title="Start selection">
    Position your cursor where you want to start the block
  </Step>

  <Step title="Create rectangular region">
    Press `Alt+Shift+↓` to extend down and `Alt+Shift+→` to extend right, creating a rectangular selection
  </Step>

  <Step title="Edit or copy">
    Type to replace the block, or `Ctrl+C` to copy only the rectangular region
  </Step>
</Steps>

<Tip>
  **Converting to Multi-Cursor**: When you type or perform an editing action with a block selection, Fresh automatically converts it to multiple cursors — one for each line in the block. This gives you the power of multi-cursor editing with the precision of rectangular selection.
</Tip>

## Selection Commands

Fresh provides powerful selection commands for quickly selecting text:

| Shortcut              | Action                        |
| --------------------- | ----------------------------- |
| `Ctrl+W`              | Select word under cursor      |
| `Ctrl+L`              | Select current line           |
| `Ctrl+A`              | Select all text in buffer     |
| `Shift+Arrow`         | Extend selection by character |
| `Ctrl+Shift+←/→`      | Select word left/right        |
| `Shift+Home/End`      | Select to line start/end      |
| `Ctrl+Shift+Home/End` | Select to document start/end  |
| `Shift+PgUp/PgDn`     | Select page up/down           |

## Basic Editing Operations

### Clipboard Operations

| Shortcut | Action               |
| -------- | -------------------- |
| `Ctrl+C` | Copy selection       |
| `Ctrl+X` | Cut selection        |
| `Ctrl+V` | Paste from clipboard |

<Note>
  With block selections, `Ctrl+C` copies only the rectangular region, not the entire lines.
</Note>

### Deletion

| Shortcut         | Action                            |
| ---------------- | --------------------------------- |
| `Backspace`      | Delete character backward         |
| `Del`            | Delete character forward          |
| `Ctrl+Backspace` | Delete word backward              |
| `Ctrl+Del`       | Delete word forward               |
| `Ctrl+K`         | Delete from cursor to end of line |

<Tip>
  `Ctrl+K` works like Emacs/Bash — it deletes from the cursor position to the end of the line.
</Tip>

### Indentation

| Shortcut    | Action                         |
| ----------- | ------------------------------ |
| `Tab`       | Indent selection or insert tab |
| `Shift+Tab` | Dedent selection               |

### Code Comments

| Shortcut | Action                                        |
| -------- | --------------------------------------------- |
| `Ctrl+/` | Toggle line comment (works with multi-cursor) |

<Tip>
  The comment syntax is automatically detected from the file type. Works with C-style `//`, Python `#`, and more.
</Tip>

### Other Editing

| Shortcut | Action                                                        |
| -------- | ------------------------------------------------------------- |
| `Ctrl+T` | Transpose characters (swap character before and after cursor) |

## Text Transformation

Transform selected text with these commands (available from the command palette):

<CardGroup cols={2}>
  <Card title="Case Conversion" icon="text">
    * `Alt+U` — Convert selection to UPPERCASE
    * `Alt+L` — Convert selection to lowercase
  </Card>

  <Card title="Line Operations" icon="arrows-up-down">
    * **Sort Lines** — Sort selected lines alphabetically
    * **Trim Trailing Whitespace** — Remove trailing spaces from all lines
  </Card>
</CardGroup>

### Automatic Cleanup on Save

You can configure Fresh to automatically clean up files when saving:

```json config.json theme={null}
{
  "trim_trailing_whitespace_on_save": true,
  "ensure_final_newline_on_save": true
}
```

## Code Folding

Collapse and expand code blocks to focus on what matters:

<Steps>
  <Step title="Enable LSP">
    Code folding requires an LSP server that supports `foldingRange`. See [LSP Configuration](/features/lsp).
  </Step>

  <Step title="Click gutter indicator">
    Click the fold indicator in the gutter to collapse a code block
  </Step>

  <Step title="Expand">
    Click again to expand, or use "Toggle Fold" from the command palette
  </Step>
</Steps>

<Note>
  * Navigation (up/down arrows) automatically skips over folded regions
  * Each split view maintains its own independent fold state
</Note>

## Vertical Rulers

Add visual column guides to enforce line length limits:

<Steps>
  <Step title="Add ruler">
    Open the command palette (`Ctrl+P`) and search for "Add Ruler"
  </Step>

  <Step title="Enter column">
    Enter the column number (e.g., `80` or `120`)
  </Step>

  <Step title="Remove ruler">
    Use "Remove Ruler" from the command palette
  </Step>
</Steps>

Rulers are per-buffer. You can also set default rulers in your config:

```json config.json theme={null}
{
  "rulers": [80, 120]
}
```

## Auto-Save

Fresh supports two types of auto-save:

<Tabs>
  <Tab title="User Auto-Save">
    Enable automatic saving at regular intervals:

    ```json config.json theme={null}
    {
      "auto_save_enabled": true,
      "auto_save_interval": 30  // seconds
    }
    ```

    Default interval is 30 seconds.
  </Tab>

  <Tab title="Crash Recovery">
    Fresh automatically saves recovery data every 2 seconds to a separate recovery directory. This runs independently of user auto-save and helps you recover work after unexpected crashes.

    Recovery files are stored in your system's temporary directory.
  </Tab>
</Tabs>

## Keyboard Macros

Record and replay sequences of keystrokes to automate repetitive tasks:

| Shortcut | Action                   |
| -------- | ------------------------ |
| `F5`     | Stop macro recording     |
| `F4`     | Play last recorded macro |

### Using Macros

<Steps>
  <Step title="Start recording">
    Open command palette (`Ctrl+P`) and search for "Record Macro". Enter a register name (0-9).
  </Step>

  <Step title="Perform actions">
    Execute the keystrokes you want to record (typing, navigation, editing, etc.)
  </Step>

  <Step title="Stop recording">
    Press `F5` or use "Stop Recording" from the command palette
  </Step>

  <Step title="Play back">
    Press `F4` to replay the last macro, or use "Play Macro" to choose a specific register
  </Step>
</Steps>

### Custom Macro Keybindings

Bind specific keys to play macros automatically:

```json config.json theme={null}
{
  "keybindings": [
    {
      "key": "!",
      "modifiers": ["alt"],
      "action": "play_macro",
      "args": {"char": "1"},
      "when": "normal"
    },
    {
      "key": "@",
      "modifiers": ["alt"],
      "action": "play_macro",
      "args": {"char": "2"},
      "when": "normal"
    }
  ]
}
```

This binds `Alt+Shift+1` to play macro 1 and `Alt+Shift+2` to play macro 2.

## Shell Integration

Run shell commands on your buffer or selection:

| Shortcut       | Action                                               |
| -------------- | ---------------------------------------------------- |
| `Alt+\|`       | Run shell command on buffer/selection (output shown) |
| `Alt+Shift+\|` | Run shell command and replace selection with output  |

### Examples

<CodeGroup>
  ```bash Sort lines theme={null}
  # Select lines, then Alt+Shift+|
  sort
  ```

  ```bash Format JSON theme={null}
  # Select JSON, then Alt+Shift+|
  jq .
  ```

  ```bash Count words theme={null}
  # Select text, then Alt+|
  wc -w
  ```
</CodeGroup>

## Markdown Editing

Smart editing features for Markdown files (provided by the built-in `markdown_source` plugin):

<CardGroup cols={2}>
  <Card title="List Continuation" icon="list">
    Pressing **Enter** on a list item automatically continues the list with the same marker (bullets, numbers, checkboxes)
  </Card>

  <Card title="Smart List Removal" icon="xmark">
    Pressing **Enter** on an empty list marker removes it
  </Card>

  <Card title="List Indentation" icon="indent">
    **Tab** indents list items and cycles through bullet styles (`-`, `*`, `+`)
  </Card>

  <Card title="Quote Handling" icon="quote-left">
    Single-quote auto-close is disabled so apostrophes don't interfere with typing
  </Card>
</CardGroup>

### Compose Mode (Experimental)

Enable distraction-free Markdown writing:

<Steps>
  <Step title="Enable compose">
    Open command palette and search for "Markdown: Toggle Compose"
  </Step>

  <Step title="Enjoy clean view">
    Markup like `**`, `*`, `[]()` is concealed, soft line breaks are applied, and tables are rendered
  </Step>

  <Step title="Adjust width">
    Use "Markdown: Set Compose Width" to change the text width
  </Step>

  <Step title="Side-by-side view">
    Open the same file in a vertical split to see source and composed views simultaneously
  </Step>
</Steps>

## Related Documentation

<CardGroup cols={3}>
  <Card title="Multi-Cursor Guide" icon="arrows-split-up-and-left" href="/features/multi-cursor">
    Detailed multi-cursor editing workflows
  </Card>

  <Card title="Search & Replace" icon="magnifying-glass" href="/features/search-replace">
    Find and replace text in files
  </Card>

  <Card title="Navigation" icon="compass" href="/features/navigation">
    Moving around your codebase
  </Card>
</CardGroup>


Built with [Mintlify](https://mintlify.com).