101 lines
5.5 KiB
Markdown
101 lines
5.5 KiB
Markdown
# File view: Diff
|
|
|
|
The Diff is a full-screen, side-by-side comparison of a changed file. It covers the whole window: the old version on the left, the current version on the right, lines aligned.
|
|
|
|
[Guide index](index.md) · Related: [File view](file-view.md), [Git](git.md), [Pass on to Agent](pass-on-to-agent.md), [Right-click menu](right-click-menu.md)
|
|
|
|
## At a glance
|
|
|
|
```text
|
|
+----------------------------------------------------------------------------+
|
|
| (1)[php] app/User.php (2)Modified +3 -2 (3)HEAD -> staged (4)[Collapse Esc]|
|
|
+-------------------------------------+--------------------------------------+
|
|
| (5)ORIGINAL before | (6)ACTUAL after |
|
|
+-------------------------------------+--------------------------------------+
|
|
| 10 public function name() | 10 public function name() |
|
|
| |11 return $this->first; (7) | |11 return $this->full; (8) |
|
|
| |12 // old | (9) |
|
|
| 13 } | 12 } |
|
|
+-------------------------------------+--------------------------------------+
|
|
```
|
|
|
|
1. **File**: the type badge and the path.
|
|
2. **Status and counts**: `Added`, `Modified` or `Deleted`, then added lines in teal (`+3`) and removed lines in amber-deep (`-2`).
|
|
3. **Which half**: only when the file has both staged and unstaged changes. `HEAD -> staged` shows the staged part, `staged -> actual` shows the part not yet staged.
|
|
4. **Collapse**: closes the Diff. Same as `Esc`.
|
|
5. **Original**: the file as it was before (left).
|
|
6. **Actual**: the file as it is now (right).
|
|
7. **Removed or old line**: amber-deep tint, left rule and number.
|
|
8. **Added or new line**: teal tint, left rule and number.
|
|
9. **Filler**: an empty half where the other side has a line with no partner.
|
|
|
|
## Features
|
|
|
|
### Open the Diff
|
|
- Click **Diff** in the [file view](file-view.md) bar. The button shows only on a file with git changes.
|
|
- Right-click a marked (teal) line in the file view and choose **Show diff**. The Diff opens centred on that line.
|
|
- Show diff on a marked line always compares the last commit with the file on disk.
|
|
- The [Git](git.md) view has its own inline diff per file row. **Open in editor** on a row opens the file; click **Diff** there for the full-screen view.
|
|
|
|
### Layout
|
|
- The Diff covers all columns. The window's shortcuts still work over it.
|
|
- Each side has its own line numbers, the numbers of that version of the file.
|
|
- Unchanged lines line up side by side. A run of removed lines pairs with the run of added lines next to it. Extra lines face an empty half.
|
|
- Both halves scroll together, up and down and sideways.
|
|
- Lines never wrap, so the rows stay aligned. Scroll sideways to read long lines.
|
|
- Syntax colours stay on, line by line.
|
|
- The text size follows View > Zoom (`Cmd++`, `Cmd+-`, `Cmd+0`).
|
|
|
|
### Colours
|
|
- Teal is what the file holds now. Changed lines on the right get a teal tint, a teal left rule and a teal number.
|
|
- Amber-deep is what it held before. Changed lines on the left get an amber-deep tint, rule and number.
|
|
- There is no green and no red.
|
|
|
|
### Special cases
|
|
- **Added file**: the left side is empty, the right side holds the whole file.
|
|
- **Deleted file**: the left side holds the old file, the right side is empty.
|
|
- **Too big**: a changed file over 1 MB shows "Too big." in place of the lines.
|
|
- **No changes**: if the file has no changes left, the Diff shows "No changes to compare."
|
|
- The Diff updates by itself when the file changes on disk or in git.
|
|
|
|
### Select and copy
|
|
- Drag over lines on one side to select whole lines. The selection stays on the side where you started.
|
|
- `Cmd+C` copies the selected lines of that side, without line numbers.
|
|
- `Cmd+A` selects every line of the side that holds the selection, or of the Original side.
|
|
- A click clears the selection.
|
|
|
|
### Right-click and pass on
|
|
- Right-click a line on either side for a small menu with **Pass on reference** and **Copy reference**.
|
|
- The reference is `path:line` with the line number of the side you clicked. An empty half refers to line 1.
|
|
- **Copy reference** puts the reference on the clipboard.
|
|
- **Pass on reference** opens the pass-on prompt inside the Diff. Type an optional note, press `Enter` to insert it into the [Claude Code](claude-code.md) pane. See [Pass on to Agent](pass-on-to-agent.md).
|
|
- Use `Up`, `Down` and `Enter` to pick a menu item with the keyboard.
|
|
|
|
### Close the Diff
|
|
- Press `Esc` or click **Collapse**.
|
|
- `Esc` closes the innermost layer first: the menu, then the prompt, then the Diff.
|
|
- You return to the view you came from, with the keyboard back in the code.
|
|
|
|
## Keyboard
|
|
|
|
| Keys | Action |
|
|
|---|---|
|
|
| `Esc` | Close the menu, the prompt, or the Diff |
|
|
| `Cmd+C` | Copy the selected lines |
|
|
| `Cmd+A` | Select all lines of one side |
|
|
| `Up` / `Down` / `Enter` | Move through and choose in the right-click menu |
|
|
| `Cmd++` / `Cmd+-` / `Cmd+0` | Zoom in / zoom out / actual size |
|
|
|
|
## Settings
|
|
|
|
| Setting | Default | Effect |
|
|
|---|---|---|
|
|
| `git.defaultDiffMode` | `updated` | Meant to open changed files straight in the Diff when set to `diff`. In this version a changed file always opens in the live file view. |
|
|
|
|
## Related
|
|
|
|
- [File view](file-view.md): the live view with teal line marks, where **Show diff** opens the Diff.
|
|
- [Git](git.md): the Git view, with an inline diff per changed file.
|
|
- [Pass on to Agent](pass-on-to-agent.md): the reference format and the prompt.
|
|
- [Right-click menu](right-click-menu.md): the menus across Helder.
|