# Editing

Cursors, selections, movement, find and replace, and what happens on save.


Rip is a plain text editor with the moves you expect, plus a few that come from its syntax tree. `secondary` means ⌘ on macOS and Ctrl on Linux.

## Multiple cursors

<kbd>secondary-d</kbd> selects the word under the cursor. Press it again to add the next match. <kbd>secondary-k secondary-d</kbd> skips the current match and takes the next one. <kbd>secondary-shift-l</kbd> selects every match at once.

<kbd>secondary-alt-up</kbd> and <kbd>secondary-alt-down</kbd> add a cursor on the line above or below. <kbd>alt-shift-i</kbd> turns one selection into a cursor at the end of each of its lines. Hold <kbd>alt</kbd> and click to add a cursor anywhere. <kbd>escape</kbd> returns to one cursor.

## Selection

<kbd>secondary-l</kbd> selects the line, and <kbd>secondary-a</kbd> selects the whole file. <kbd>alt-up</kbd> grows the selection to the enclosing syntax node: a word, then an expression, then a block. <kbd>alt-down</kbd> shrinks it again. <kbd>shift</kbd> with any movement key extends the selection.

## Movement

| Keys | Moves |
| --- | --- |
| <kbd>alt-left</kbd> / <kbd>alt-right</kbd> | By word. |
| <kbd>secondary-left</kbd> / <kbd>secondary-right</kbd> | To the start or the end of the line. |
| <kbd>secondary-up</kbd> / <kbd>secondary-down</kbd> | To the start or the end of the file. |
| <kbd>pageup</kbd> / <kbd>pagedown</kbd> | By one screen. |
| <kbd>alt-]</kbd> / <kbd>alt-[</kbd> | To the next or the previous changed hunk. |
| <kbd>ctrl-g</kbd> | To a line number. |

To move the current line up or down, press <kbd>ctrl-secondary-up</kbd> or <kbd>ctrl-secondary-down</kbd> on macOS. On Linux, press <kbd>ctrl-shift-up</kbd> or <kbd>ctrl-shift-down</kbd>.

## Change text

| Keys | What happens |
| --- | --- |
| <kbd>secondary-z</kbd> / <kbd>secondary-shift-z</kbd> | Undo and redo. |
| <kbd>secondary-shift-d</kbd> | Duplicate the line. |
| <kbd>secondary-shift-k</kbd> | Delete the line. |
| <kbd>ctrl-j</kbd> | Join the line with the next one. |
| <kbd>secondary-/</kbd> | Comment or uncomment the selection. |
| <kbd>secondary-]</kbd> / <kbd>secondary-[</kbd> | Indent or outdent. |
| <kbd>secondary-enter</kbd> / <kbd>secondary-shift-enter</kbd> | Start a new line below or above. |
| <kbd>alt-backspace</kbd> / <kbd>alt-delete</kbd> | Delete to the start or the end of the word. |
| <kbd>secondary-backspace</kbd> / <kbd>secondary-delete</kbd> | Delete to the start or the end of the line. |
| <kbd>alt-z</kbd> | Turn soft wrap on or off for this file. |

## Find and replace

<kbd>secondary-f</kbd> opens the search bar. Type, and Rip highlights every match. <kbd>enter</kbd> goes to the next match and <kbd>shift-enter</kbd> to the previous one. <kbd>secondary-g</kbd> and <kbd>secondary-shift-g</kbd> do the same from the editor. <kbd>escape</kbd> closes the bar.

<kbd>secondary-alt-f</kbd> opens the replace field. <kbd>secondary-enter</kbd> replaces the current match, and <kbd>secondary-alt-enter</kbd> replaces every match. To search every file in the folder, see [Search and traces](/docs/search-and-traces.md).

## Save

<kbd>secondary-s</kbd> saves the file, <kbd>secondary-shift-s</kbd> saves it under a new name, and <kbd>secondary-alt-s</kbd> saves every open file. On save, Rip removes trailing whitespace and adds a final newline when the settings below say so.

A file can change on disk while you edit it. Rip merges the two versions and never writes over the change on disk. [Working with agents](/docs/working-with-agents.md#your-edits-stay-yours) explains the merge and the keys for a conflict.

## Settings

| Key | What it changes |
| --- | --- |
| `tab-size` | The width of a tab, and the size of one indent. |
| `indent` | Whether <kbd>tab</kbd> inserts spaces or a tab. |
| `soft-wrap` | Whether long lines wrap at the window edge. |
| `line-numbers` | Whether the gutter shows line numbers. |
| `relative-line-numbers` | Whether line numbers count from the cursor. |
| `cursor-blink` | Whether the cursor blinks. |
| `show-whitespace` | When to draw spaces and tabs: never, always, or in a selection. |
| `indent-guides` | Whether indent levels get a guide line. |
| `trim-trailing-whitespace-on-save` | Remove spaces at the end of each line on save. |
| `ensure-final-newline-on-save` | End the file with a newline on save. |
