{"schemaVersion":1,"contentVersion":"3.4.0","id":"intermediate.5","languages":{"javascript":{"id":"intermediate.5","title":"Copy and move text","moduleName":"Boundaries and reusable text","tips":"","concept":"<p class=\"lead\">Know where Vim puts a copied line and where it puts a copied word.</p><p><strong>Before this lesson:</strong> Operators and line boundaries.</p><p>y copies, and d deletes and copies. yy and dd work on whole lines, so p puts the line below the current one and P puts it above. A copied word, such as one from yiw, goes after the cursor with p or before it with P. Be careful, because the next delete replaces what p puts.</p><h3>Example</h3><p>With the cursor on the first line of a checklist, yy then p puts a copy of it below. dd then p moves the line instead, because dd removes the original.</p><p>Use Start over to try again.</p>","teaches":["linewise","put:p"],"introduces":["y","p","P","yy","dd","linewise"],"constraints":[],"drills":[{"task":"Next.js only reads <code>\"use client\";</code> on the first line of the file. Move it there.","hint":"dd takes the line with it. P puts a line above the cursor's line, so it works on the first line too.","mode":"jsx","start":"import { useTransition } from \"react\";\nimport { addToCart } from \"../cart/actions\";\n\"use client\";\n\n// The Add to cart button on a product page. It needs state, so it runs in the browser.\nexport function AddToCart({ productId }) {\n  const [pending, startTransition] = useTransition();\n  return <button disabled={pending} onClick={() => startTransition(() => addToCart(productId))}>Add to cart</button>;\n}","startCursor":{"line":2,"ch":0},"paths":[{"keys":["d","d","g","g","P"],"tier":"idiomatic","technique":"put:P","core":["put:P","linewise"],"note":"P puts the line above the first line. p would put it below, as the second line."}],"target":"\"use client\";\nimport { useTransition } from \"react\";\nimport { addToCart } from \"../cart/actions\";\n\n// The Add to cart button on a product page. It needs state, so it runs in the browser.\nexport function AddToCart({ productId }) {\n  const [pending, startTransition] = useTransition();\n  return <button disabled={pending} onClick={() => startTransition(() => addToCart(productId))}>Add to cart</button>;\n}","language":"javascript","evidence":"guided","canonicalKey":"intermediate.5#0","canonicalFingerprint":"1qawwg5"},{"task":"Name the test suite after the function it tests, <code>formatShippingEstimate</code>.","hint":"yiw copies the word under the cursor. p puts it after the cursor, so stand on the first quote.","mode":"jsx","start":"import { formatShippingEstimate } from \"./shipping\";\n\nconst MONDAY = new Date(\"2026-11-16\");\n\ndescribe(\"\", () => {\n  it(\"says tomorrow for items in stock\", () => {\n    expect(formatShippingEstimate({ inStock: true }, MONDAY)).toBe(\"Arrives tomorrow\");\n  });\n});","startCursor":{"line":0,"ch":15},"paths":[{"keys":["y","i","w","5","G","f","\"","p"],"tier":"idiomatic","technique":"put:p","core":["put:p","operator:y"],"note":"yiw copies the whole name from anywhere inside it, and p puts it between the quotes."}],"target":"import { formatShippingEstimate } from \"./shipping\";\n\nconst MONDAY = new Date(\"2026-11-16\");\n\ndescribe(\"formatShippingEstimate\", () => {\n  it(\"says tomorrow for items in stock\", () => {\n    expect(formatShippingEstimate({ inStock: true }, MONDAY)).toBe(\"Arrives tomorrow\");\n  });\n});","language":"javascript","evidence":"guided","canonicalKey":"intermediate.5#1","canonicalFingerprint":"18bsgpu"}]},"python":{"id":"intermediate.5","title":"Copy and move text","moduleName":"Boundaries and reusable text","tips":"","concept":"<p class=\"lead\">Know where Vim puts a copied line and where it puts a copied word.</p><p><strong>Before this lesson:</strong> Operators and line boundaries.</p><p>y copies, and d deletes and copies. yy and dd work on whole lines, so p puts the line below the current one and P puts it above. A copied word, such as one from yiw, goes after the cursor with p or before it with P. Be careful, because the next delete replaces what p puts.</p><h3>Example</h3><p>With the cursor on the first line of a checklist, yy then p puts a copy of it below. dd then p moves the line instead, because dd removes the original.</p><p>Use Start over to try again.</p>","teaches":["linewise","put:p"],"introduces":["y","p","P","yy","dd","linewise"],"constraints":[],"drills":[{"task":"Python only accepts <code>from __future__</code> imports at the top of the file. Move it there.","hint":"dd takes the line with it. P puts a line above the cursor's line, so it works on the first line too.","mode":"python","start":"from dataclasses import dataclass, field\nfrom shop.money import Money\nfrom __future__ import annotations\n\n\n@dataclass\nclass Refund:\n    \"\"\"Money going back to a customer. Partial refunds keep the order open.\"\"\"\n    order_number: str\n    amount: Money\n    reasons: list[str] = field(default_factory=list)","startCursor":{"line":2,"ch":0},"paths":[{"keys":["d","d","g","g","P"],"tier":"idiomatic","technique":"put:P","core":["put:P","linewise"],"note":"P puts the line above the first line. p would put it below, as the second line."}],"target":"from __future__ import annotations\nfrom dataclasses import dataclass, field\nfrom shop.money import Money\n\n\n@dataclass\nclass Refund:\n    \"\"\"Money going back to a customer. Partial refunds keep the order open.\"\"\"\n    order_number: str\n    amount: Money\n    reasons: list[str] = field(default_factory=list)","language":"python","evidence":"guided","canonicalKey":"intermediate.5#0","canonicalFingerprint":"1qawwg5"},{"task":"Name the test after the function it tests: <code>test_format_shipping_estimate</code>.","hint":"yiw copies the word under the cursor, and p puts it after the cursor.","mode":"python","start":"from datetime import date\n\nfrom shop.shipping import format_shipping_estimate\n\nMONDAY = date(2026, 11, 16)\n\n\ndef test_():\n    assert format_shipping_estimate(in_stock=True, today=MONDAY) == \"Arrives tomorrow\"","startCursor":{"line":2,"ch":29},"paths":[{"keys":["y","i","w","G","k","f","_","p"],"tier":"idiomatic","technique":"put:p","core":["put:p","operator:y"],"note":"yiw copies the whole name from anywhere inside it, and p puts it after test_."}],"target":"from datetime import date\n\nfrom shop.shipping import format_shipping_estimate\n\nMONDAY = date(2026, 11, 16)\n\n\ndef test_format_shipping_estimate():\n    assert format_shipping_estimate(in_stock=True, today=MONDAY) == \"Arrives tomorrow\"","language":"python","evidence":"guided","canonicalKey":"intermediate.5#1","canonicalFingerprint":"18bsgpu"}]},"text":{"id":"intermediate.5","title":"Copy and move text","moduleName":"Boundaries and reusable text","tips":"","concept":"<p class=\"lead\">Know where Vim puts a copied line and where it puts a copied word.</p><p><strong>Before this lesson:</strong> Operators and line boundaries.</p><p>y copies, and d deletes and copies. yy and dd work on whole lines, so p puts the line below the current one and P puts it above. A copied word, such as one from yiw, goes after the cursor with p or before it with P. Be careful, because the next delete replaces what p puts.</p><h3>Example</h3><p>With the cursor on the first line of a checklist, yy then p puts a copy of it below. dd then p moves the line instead, because dd removes the original.</p><p>Use Start over to try again.</p>","teaches":["linewise","put:p"],"introduces":["y","p","P","yy","dd","linewise"],"constraints":[],"drills":[{"task":"The title should be the first line of the file. Move it there.","hint":"dd takes the line with it. P puts a line above the cursor's line, so it works on the first line too.","mode":"text/plain","start":"Last updated in November.\nOwner: Dana, release team.\n# Release day checklist\n\n- Run the tests on the release branch.\n- Bump the version in package.json.\n- Post the release notes in the team channel.","startCursor":{"line":2,"ch":0},"paths":[{"keys":["d","d","g","g","P"],"tier":"idiomatic","technique":"put:P","core":["put:P","linewise"],"note":"P puts the line above the first line. p would put it below, as the second line."}],"target":"# Release day checklist\nLast updated in November.\nOwner: Dana, release team.\n\n- Run the tests on the release branch.\n- Bump the version in package.json.\n- Post the release notes in the team channel.","language":"text","evidence":"guided","canonicalKey":"intermediate.5#0","canonicalFingerprint":"1qawwg5"},{"task":"Finish the second command: its logs are under the same service name, <code>northwind_checkout</code>.","hint":"yiw copies the word under the cursor, and p puts it after the cursor.","mode":"text/plain","start":"# On call: checkout\n\nIf checkout stops answering, restart it:\n\n    systemctl restart northwind_checkout\n\nThen check its logs for the cause:\n\n    journalctl --since today -u","startCursor":{"line":4,"ch":26},"paths":[{"keys":["y","i","w","G","A"," ","<Esc>","p"],"tier":"idiomatic","technique":"put:p","core":["put:p","operator:y"],"note":"yiw copies the whole name from anywhere inside it, and p puts it after the cursor."}],"target":"# On call: checkout\n\nIf checkout stops answering, restart it:\n\n    systemctl restart northwind_checkout\n\nThen check its logs for the cause:\n\n    journalctl --since today -u northwind_checkout","language":"text","evidence":"guided","canonicalKey":"intermediate.5#1","canonicalFingerprint":"18bsgpu"}]}},"concepts":{"javascript":{"lead":"","reminder":"<p class=\"lesson-prereq\"><strong>Before this lesson:</strong> Operators and line boundaries.</p>","more":"<details class=\"lesson-more\"><summary>More about this lesson</summary><div class=\"lesson-more-body prose\"><p class=\"lead\">Know where Vim puts a copied line and where it puts a copied word.</p><p>y copies, and d deletes and copies. yy and dd work on whole lines, so p puts the line below the current one and P puts it above. A copied word, such as one from yiw, goes after the cursor with p or before it with P. Be careful, because the next delete replaces what p puts.</p><h2 class=\"prose-subhead\">Example</h2><p>With the cursor on the first line of a checklist, yy then p puts a copy of it below. dd then p moves the line instead, because dd removes the original.</p><p>Use Start over to try again.</p></div></details>"},"python":{"lead":"","reminder":"<p class=\"lesson-prereq\"><strong>Before this lesson:</strong> Operators and line boundaries.</p>","more":"<details class=\"lesson-more\"><summary>More about this lesson</summary><div class=\"lesson-more-body prose\"><p class=\"lead\">Know where Vim puts a copied line and where it puts a copied word.</p><p>y copies, and d deletes and copies. yy and dd work on whole lines, so p puts the line below the current one and P puts it above. A copied word, such as one from yiw, goes after the cursor with p or before it with P. Be careful, because the next delete replaces what p puts.</p><h2 class=\"prose-subhead\">Example</h2><p>With the cursor on the first line of a checklist, yy then p puts a copy of it below. dd then p moves the line instead, because dd removes the original.</p><p>Use Start over to try again.</p></div></details>"},"text":{"lead":"","reminder":"<p class=\"lesson-prereq\"><strong>Before this lesson:</strong> Operators and line boundaries.</p>","more":"<details class=\"lesson-more\"><summary>More about this lesson</summary><div class=\"lesson-more-body prose\"><p class=\"lead\">Know where Vim puts a copied line and where it puts a copied word.</p><p>y copies, and d deletes and copies. yy and dd work on whole lines, so p puts the line below the current one and P puts it above. A copied word, such as one from yiw, goes after the cursor with p or before it with P. Be careful, because the next delete replaces what p puts.</p><h2 class=\"prose-subhead\">Example</h2><p>With the cursor on the first line of a checklist, yy then p puts a copy of it below. dd then p moves the line instead, because dd removes the original.</p><p>Use Start over to try again.</p></div></details>"}}}