# Buffers and windows

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

Arrange files in splits, move between editor and plugin panes, and resolve files that changed outside Red.

<a id="move-between-buffers"></a>

## Move between buffers

`Ctrl-j`Open the buffer picker

`Space Space`Switch to the previous buffer

`Space n / Space p`Move through the buffer list

`:bn / :bp`Select the next or previous buffer

`:bd`Delete the current buffer

`:ls`List open buffers

<a id="browse-directories-in-a-buffer"></a>

## Browse directories in a buffer

Run `red .` or open a directory with `:e path/to/dir`. Move and search with normal editor keys, press `Enter` to open an entry, and press `-` to go to the parent directory. Use `R` to refresh the listing. Directory buffers are read-only and stay in the buffer list so you can return to them.

<a id="arrange-windows-and-panes"></a>

## Arrange windows and panes

| Keys             | Action                                           |
| ---------------- | ------------------------------------------------ |
| `Ctrl-w s`       | Split horizontally                               |
| `Ctrl-w v`       | Split vertically                                 |
| `Ctrl-w h/j/k/l` | Move between editor windows and docked panes     |
| `Ctrl-w H/J/K/L` | Move the focused window or pane to an outer edge |
| `Ctrl-w >/<`     | Resize horizontally                              |
| `Ctrl-w +/-`     | Resize vertically                                |
| `Ctrl-w =`       | Balance splits or restore a pane's original size |
| `Ctrl-w z`       | Zoom the focused editor window or pane           |
| `Ctrl-w c`       | Close the focused window                         |

You can also drag editor and pane dividers with the mouse. Press `Esc` during a drag to cancel it.

<a id="handle-a-file-changed-on-disk"></a>

## Handle a file changed on disk

Red reloads a clean buffer when another program changes its file. If the buffer has unsaved edits, Red keeps your text and marks the conflict instead of overwriting either version.

`:diffdisk`Compare the buffer with the current disk version

`:e!`Discard local edits and reload from disk

`:w file`Save the buffer under another name

`:w!`Deliberately overwrite the changed disk file

Ordinary `:w` and `:wa` don't silently overwrite an external change.
