# Navigate and edit

Canonical HTML: [Navigate and edit](https://getred.dev/docs/editor/navigation). Website source: `b212874eefaf200143affa21c770fbb8855a4f5c`. Documented Red release: v0.9.1. Installer source: `b86a2ca4b92e9547d3b174910c82db8a259f5171`.

Move through a project with Red's file tools and use its Vim-style editing model without guessing which commands are available.

<a id="open-files-and-projects"></a>

## Open files and projects

```shell
red src/main.rs
red src/main.rs src/lib.rs
red -r path/to/project src/main.rs
```

The `-r` option sets the workspace root explicitly. Inside Red, press `Ctrl-p` for the file picker, `Ctrl-j` or `Space b` for open buffers, and `Ctrl-e` for the file tree.

Add a line number to a file-picker query to open that location. For example, `render:240` opens the selected matching file at line 240.

Press `Alt-p` or `F4` in the file, buffer, or project-search picker to hide or restore its preview. Your query and selection stay in place while long paths get more room.

<a id="move-in-normal-mode"></a>

## Move in Normal mode

`h j k l`Move left, down, up, and right

`w b e`Move by word

`0 ^ $`Move to line boundaries

`gg / G`Move to the first or last line

`Ctrl-u / Ctrl-d`Move half a page

`Ctrl-o / Ctrl-i`Move backward or forward through jumps

Use `gj` and `gk` to move by displayed rows when long lines wrap.

<a id="edit-with-motions"></a>

## Edit with motions

Operators combine with motions and text objects. `dw` deletes a word, `ci(` changes inside parentheses, and `y$` copies to the end of the line. Counts work with supported actions: `3dw` deletes three words.

| Keys           | Result                                      |
| -------------- | ------------------------------------------- |
| `i`, `a`, `o`  | Enter Insert mode at common positions       |
| `x`, `dd`, `D` | Delete a character, line, or to line end    |
| `u`, `Ctrl-r`  | Undo and redo                               |
| `p`, `P`       | Paste after or before the cursor            |
| `.`            | Repeat the last completed change            |
| `:w`, `:wa`    | Save the current file or all modified files |

<a id="use-syntax-aware-movement"></a>

## Use syntax-aware movement

When the current language supplies structural queries, `]f` and `[f` move between functions, `]c` and `[c` move between classes, and `]m` and `[m` move between calls. Use `af`, `if`, `ac`, `ic`, `am`, or `im` as Visual selections or operator targets.

<a id="edit-repeated-text-with-multiple-cursors"></a>

## Edit repeated text with multiple cursors

Press `Ctrl-n` on a word to select it, then press it again to add the next occurrence. Use `q` to skip one match, `Q` to remove the active selection, and `n` or `N` to move through matches. Press `c`, type the replacement, and press `Esc`; one `u` undoes the complete multi-cursor edit.

`Ctrl-Up` and `Ctrl-Down` add vertical cursors while preserving display columns across tabs and spaces.
