Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 33 additions & 4 deletions content/docs/learn/playground/clipboard.mdx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
title: "Copy, cut, and paste"
description: "Copy adjusts references to the paste target; cut moves a cell verbatim."
description: "Copy adjusts references to the paste target; cut moves the range and rewrites every reference into it — inside the moved range or anywhere else on the sheet — to follow, with a dashed border marking a pending cut and no clipboard-permission prompt on paste."
---

{/* GENERATED — do not edit by hand */}
Expand All @@ -10,11 +10,12 @@ description: "Copy adjusts references to the paste target; cut moves a cell verb
Select a cell and press **Ctrl+C** to copy or **Ctrl+X** to cut, then select a target and press **Ctrl+V** to paste.

- **Copy + paste** adjusts the formula's relative references by the paste offset — `=A1+B1` copied from **C1** to **C3** becomes `=A3+B3`, while `$`-anchored parts stay put (`=$A$1+B1` → `=$A$1+B3`). The source is left untouched and the clipboard stays loaded, so you can paste it again.
- **Cut + paste** _moves_ the cell: the formula is written to the destination **verbatim** (no reference adjustment) and the source cell is cleared. The clipboard is consumed after that one paste.
- **Cut + paste** _moves_ the range: every reference into the cut range follows it to its new address — whether that reference is in a formula that's itself part of the moved range, or in a completely different cell elsewhere on the sheet. A reference to something outside the cut range is left exactly as written. The source is cleared and the clipboard is consumed after that one paste.
- While a cut is pending, the cut range is marked with a dashed border so it reads as distinct from a plain selection, and pasting never interrupts you for clipboard permission.

## Verified behavior

_Matches Google Sheets:_ In Google Sheets, copying a formula and pasting it adjusts the formula's relative references by the row/column offset (copying "=A1+B1" from C1 to C3 yields "=A3+B3"), while $-anchored parts stay fixed ("=$A$1+B1" → "=$A$1+B3"); copy leaves the source and the clipboard intact, so it can be pasted again. Cutting and pasting instead MOVES the cell: the formula is written to the destination verbatim (no reference adjustment) and the source is cleared, and the clipboard is consumed after that one paste. (Sheets additionally rewrites OTHER formulas that referenced the moved cell so they keep pointing at it — that cross-reference remap needs engine support and is not yet modeled here; tracked as a follow-up.)
_Matches Google Sheets:_ In Google Sheets, copying a formula and pasting it adjusts the formula's relative references by the row/column offset (copying "=A1+B1" from C1 to C3 yields "=A3+B3"), while $-anchored parts stay fixed ("=$A$1+B1" → "=$A$1+B3"); copy leaves the source and the clipboard intact, so it can be pasted again. Cutting and pasting instead MOVES the range: every reference anywhere in the workbook that points at a cell inside the cut range is rewritten to follow that cell to its new address — whether the reference lives in a formula that is itself part of the moved range (e.g. cutting two cells together where one formula refers to the other) or in a completely different, untouched cell elsewhere on the sheet. A reference to a cell that was NOT part of the cut range is left exactly as written either way, since nothing it points at moved. While a cut is pending (cut but not yet pasted), Sheets marks the range with a dashed border, visually distinct from a plain selection; pasting never prompts for clipboard permission.

#### Copy a relative formula and paste — references shift by the offset

Expand Down Expand Up @@ -48,7 +49,7 @@ _Matches Google Sheets:_ In Google Sheets, copying a formula and pasting it adju
- **D3** shows `12`
- **D3** has formula `=B3+C3`

#### Cut and paste — the formula moves verbatim and the source is cleared
#### Cut and paste — a reference to a cell OUTSIDE the cut range is left as written (moves unchanged)

**Given**
- **A1** = `10`
Expand All @@ -61,3 +62,31 @@ _Matches Google Sheets:_ In Google Sheets, copying a formula and pasting it adju
- **C3** shows `30`
- **C1** shows `null`
- **C3** has formula `=A1+B1`

#### Cut and paste a block — a formula's reference to another cell in the SAME block follows the move

**Given**
- **A1** = `10`
- **A2** = `=A1*2`

**When** I select **A1:A2**, then press `Control+x`, then click **A5**, then press `Control+v`

**Then**
- **A5** shows `10`
- **A6** shows `20`
- **A1** shows `null`
- **A2** shows `null`
- **A6** has formula `=A5*2`

#### Cut and paste — an untouched formula elsewhere that referenced the cut cell follows the move too

**Given**
- **A1** = `10`
- **B1** = `=A1+5`

**When** I click **A1**, then press `Control+x`, then click **A5**, then press `Control+v`

**Then**
- **A5** shows `10`
- **B1** shows `15`
- **B1** has formula `=A5+5`
3 changes: 2 additions & 1 deletion content/docs/learn/playground/meta.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
"find-replace",
"named-ranges",
"pivot-table",
"print-page-setup"
"print-page-setup",
"reorder-rows-columns"
]
}
86 changes: 86 additions & 0 deletions content/docs/learn/playground/reorder-rows-columns.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
---
title: "Drag to reorder rows & columns"
description: "Grabbing an already-selected column or row header and dragging it (alone, or as part of a multi-selected contiguous band) relocates it to a new position — siblings shift to fill the gap and make room, and every formula reference into the moved band, or to a shifted sibling, follows the move — matching Google Sheets."
---

{/* GENERATED — do not edit by hand */}

## What it does

Grab a column-letter or row-number header that's already selected — the pointer turns into a grabbing hand — and drag it to reorder it, matching Google Sheets. While dragging, a gray highlight tracks whichever column/row the pointer is currently over, and a marker line shows exactly where the dragged column/row will land on release. Release to drop: siblings shift to fill the gap and make room, and every formula that referenced a cell in the moved column/row — including formulas that live elsewhere on the sheet entirely — keeps pointing at the same logical cell. A contiguous multi-column or multi-row selection drags as one band. The whole move is a single undoable step.

## Try it

<TrueCalc mode="standalone" seed="A1=1;B1=2;C1=3;A2==A1+B1" />

## Verified behavior

_Matches Google Sheets:_ Re-grabbing an already-selected column/row header (mousedown on a header that is already part of the current selection) and moving the pointer arms a drag: a grabbing cursor, a gray highlight over the ONE column/row currently under the pointer (the "shift target"), and a thin insertion- marker line at whichever edge of that shift-target is FARTHER from the dragged band's own original position — i.e. dragging left of the source, the marker sits at the shift-target's left edge; dragging right, its right edge. That marker is exactly where the band lands on release, confirmed against actual drop behavior, not just the in-flight visual. Releasing moves the whole band there in ONE undoable step: every column/ row between the source and the drop point shifts by the band's width to fill the vacated slot and open the new one, and every formula reference — whether it's part of the moved band itself, points at a sibling that shifted, or lives anywhere else on the sheet and simply points INTO the moved band — is rewritten to keep pointing at the same logical cell, $-blind (a structural move, not a copy — the referenced cell itself relocated). A multi-column or multi-row contiguous selection drags as one band with identical mechanics; dragging never mixes row and column selections. A mousedown on a header that is NOT already selected performs the ordinary header click/extend-selection gesture instead — the drag only arms on a re-grab of an existing selection (live-verified; see this feature's oracle brief).

#### dragging a selected column swaps it with the column it's dropped before, moving its own content and formula with it

**Given**
- **F1** = `100`
- **G1** = `10`
- **G2** = `=G1*2`

**When** I drag column **G** and drop it over column **F**

**Then**
- **F1** shows `10`
- **F2** shows `20`
- **G1** shows `100`
- **F2** has formula `=F1*2`

#### a formula elsewhere on the sheet that references into the moved column follows it to its new address

**Given**
- **G1** = `10`
- **K1** = `=G1+5`

**When** I drag column **G** and drop it over column **F**

**Then**
- **F1** shows `10`
- **K1** shows `15`
- **K1** has formula `=F1+5`

#### a multi-column band drags as one unit, preserving the relative order of its columns

**Given**
- **C1** = `1`
- **D1** = `2`

**When** I drag column **C:D** and drop it over column **F**

**Then**
- **C1** shows `null`
- **D1** shows `null`
- **E1** shows `1`
- **F1** shows `2`

#### dragging a row mirrors the column case, including the shifted sibling's own formula following the cell it references

**Given**
- **A13** = `100`
- **A14** = `10`
- **B14** = `=A14*2`

**When** I drag row **14** and drop it over row **13**

**Then**
- **A13** shows `10`
- **B13** shows `20`
- **A14** shows `100`
- **B13** has formula `=A13*2`

#### the move is undoable in one step

**Given**
- **G1** = `10`

**When** I drag column **G** and drop it over column **F**, then click **A1**, then undo

**Then**
- **F1** shows `null`
- **G1** shows `10`
Loading