{"schemaVersion":1,"contentVersion":"3.4.0","id":"intermediate.4","languages":{"javascript":{"id":"intermediate.4","title":"Make search part of an edit","moduleName":"Boundaries and reusable text","tips":"","concept":"<p class=\"lead\">Delete or change text up to a word you can see, and leave lookalike words alone.</p><p><strong>Before this lesson:</strong> Search foundations and operator grammar.</p><p>d/pattern then Enter deletes up to the next match and keeps the match itself, even when the match is on another line. c/ deletes the same text and puts you in Insert mode. When the end is a character on the same line, dt is shorter, and a WORD or two goes with d2W.</p><h3>Example</h3><p>From Remove in “Remove this; keep the note”, d/keep then Enter leaves “keep the note”. c/keep stops at the same place and lets you type new text.</p><p>Use Start over to try again.</p>","teaches":["operator-search","operator-motion","search","search:*"],"introduces":["search","d","c","*","#","e","w"],"constraints":[],"drills":[{"task":"Shorten the note: remove <code>which you can read at any time on the help page, </code>.","hint":"d/ deletes up to a search match and keeps the match. Type the start of the word to stop at, then Enter.","mode":"jsx","start":"import { translate } from \"../i18n/translate\";\n\n// Shown under the Pay button.\nexport const PAY_NOTE = translate(\n  \"By paying you accept our terms, which you can read at any time on the help page, and our privacy policy.\",\n);","startCursor":{"line":4,"ch":35},"paths":[{"keys":["d","/","and","<CR>"],"tier":"idiomatic","technique":"operator-search","core":["operator-search"],"note":"d/and deletes everything up to the next and, punctuation included, and keeps the and."}],"target":"import { translate } from \"../i18n/translate\";\n\n// Shown under the Pay button.\nexport const PAY_NOTE = translate(\n  \"By paying you accept our terms, and our privacy policy.\",\n);","language":"javascript","evidence":"guided","canonicalKey":"intermediate.4#0","canonicalFingerprint":"104pghx"},{"task":"We don't leave cards any more. Replace <code>leaves a card and tries again the next working day</code> with <code>takes the parcel to a pickup point</code>.","hint":"c/ deletes up to a search match, even on the next line, and lets you type in its place.","mode":"jsx","start":"import { render } from \"./templates\";\n\n// The email we send when the carrier marks a parcel as delivered. If the\n// customer wasn't home, the carrier leaves a card and tries again the next\n// working day, so we don't need to tell them anything else here.\nexport function deliveredEmail(order) {\n  return render(\"delivered\", { order });\n}","startCursor":{"line":5,"ch":0},"paths":[{"keys":["2","k","/","lea","<CR>","c","/",", so","<CR>","takes the parcel to a pickup point","<Esc>"],"tier":"idiomatic","technique":"operator:c","core":["operator:c","operator-search"],"note":"c/, so stops just before the comma on the next line, so the rest of the comment stays."}],"target":"import { render } from \"./templates\";\n\n// The email we send when the carrier marks a parcel as delivered. If the\n// customer wasn't home, the carrier takes the parcel to a pickup point, so we don't need to tell them anything else here.\nexport function deliveredEmail(order) {\n  return render(\"delivered\", { order });\n}","language":"javascript","evidence":"guided","canonicalKey":"intermediate.4#1","canonicalFingerprint":"890tqx"},{"task":"We don't attach the invoice any more. Remove the sentence about the PDF, which runs onto the next line.","hint":"d/ works across lines: it deletes up to the match wherever it is.","mode":"jsx","start":"import { renderTemplate } from \"./render\";\n\n// Builds the order confirmation email. We used to attach the invoice as\n// a PDF here, but customers download it from their account now. The\n// template itself lives in emails/templates/confirmation.html.\nexport function confirmationEmail(order) {\n  return renderTemplate(\"confirmation\", { order });\n}","startCursor":{"line":0,"ch":0},"paths":[{"keys":["/","We","<CR>","d","/","The","<CR>"],"tier":"idiomatic","technique":"operator-search","core":["operator-search"],"note":"The search finds The on the next line, so d/ deletes the end of this line and the start of that one."}],"target":"import { renderTemplate } from \"./render\";\n\n// Builds the order confirmation email. The\n// template itself lives in emails/templates/confirmation.html.\nexport function confirmationEmail(order) {\n  return renderTemplate(\"confirmation\", { order });\n}","language":"javascript","evidence":"guided","canonicalKey":"intermediate.4#2","canonicalFingerprint":"1nkew79"},{"task":"The API sets the content type itself. Delete the <code>Content-Type</code> header.","hint":"This one is two WORDs, the name and the value, so d2W deletes it with its space.","mode":"jsx","start":"const BASE = \"https://api.northwind.shop/v2\";\n\n// Every request sends JSON and the shop's API key.\nexport function request(path, options = {}) {\n  return fetch(BASE + path, {\n    ...options,\n    headers: { \"Content-Type\": \"application/json\", \"X-Api-Key\": import.meta.env.VITE_API_KEY },\n  });\n}","startCursor":{"line":6,"ch":4},"paths":[{"keys":["f","\"","d","2","W"],"tier":"idiomatic","technique":"count","core":["count","operator-motion"],"note":"Two WORDs with no spaces inside them: d2W is shorter than searching for where they end."}],"target":"const BASE = \"https://api.northwind.shop/v2\";\n\n// Every request sends JSON and the shop's API key.\nexport function request(path, options = {}) {\n  return fetch(BASE + path, {\n    ...options,\n    headers: { \"X-Api-Key\": import.meta.env.VITE_API_KEY },\n  });\n}","language":"javascript","evidence":"guided","canonicalKey":"intermediate.4#3","canonicalFingerprint":"1w9jo9u"}]},"python":{"id":"intermediate.4","title":"Make search part of an edit","moduleName":"Boundaries and reusable text","tips":"","concept":"<p class=\"lead\">Delete or change text up to a word you can see, and leave lookalike words alone.</p><p><strong>Before this lesson:</strong> Search foundations and operator grammar.</p><p>d/pattern then Enter deletes up to the next match and keeps the match itself, even when the match is on another line. c/ deletes the same text and puts you in Insert mode. When the end is a character on the same line, dt is shorter, and a WORD or two goes with d2W.</p><h3>Example</h3><p>From Remove in “Remove this; keep the note”, d/keep then Enter leaves “keep the note”. c/keep stops at the same place and lets you type new text.</p><p>Use Start over to try again.</p>","teaches":["operator-search","operator-motion","search","search:*"],"introduces":["search","d","c","*","#","e","w"],"constraints":[],"drills":[{"task":"Shorten the note: remove <code>which you can read at any time on the help page, </code>.","hint":"d/ deletes up to a search match and keeps the match. Type the start of the word to stop at, then Enter.","mode":"python","start":"from shop.i18n import lazy_text as _\n\n# Shown under the Pay button.\nPAY_NOTE = _(\n    \"By paying you accept our terms, which you can read at any time on the help page, and our privacy policy.\"\n)","startCursor":{"line":4,"ch":37},"paths":[{"keys":["d","/","and","<CR>"],"tier":"idiomatic","technique":"operator-search","core":["operator-search"],"note":"d/and deletes everything up to the next and, punctuation included, and keeps the and."}],"target":"from shop.i18n import lazy_text as _\n\n# Shown under the Pay button.\nPAY_NOTE = _(\n    \"By paying you accept our terms, and our privacy policy.\"\n)","language":"python","evidence":"guided","canonicalKey":"intermediate.4#0","canonicalFingerprint":"104pghx"},{"task":"We don't leave cards any more. Replace <code>leaves a card and tries again the next working day</code> with <code>takes the parcel to a pickup point</code>.","hint":"c/ deletes up to a search match, even on the next line, and lets you type in its place.","mode":"python","start":"from shop.emails.templates import render\n\n\n# The email we send when the carrier marks a parcel as delivered. If the\n# customer wasn't home, the carrier leaves a card and tries again the next\n# working day, so we don't need to tell them anything else here.\ndef delivered_email(order):\n    return render(\"delivered\", order=order)","startCursor":{"line":6,"ch":0},"paths":[{"keys":["2","k","/","lea","<CR>","c","/",", so","<CR>","takes the parcel to a pickup point","<Esc>"],"tier":"idiomatic","technique":"operator:c","core":["operator:c","operator-search"],"note":"c/, so stops just before the comma on the next line, so the rest of the comment stays."}],"target":"from shop.emails.templates import render\n\n\n# The email we send when the carrier marks a parcel as delivered. If the\n# customer wasn't home, the carrier takes the parcel to a pickup point, so we don't need to tell them anything else here.\ndef delivered_email(order):\n    return render(\"delivered\", order=order)","language":"python","evidence":"guided","canonicalKey":"intermediate.4#1","canonicalFingerprint":"890tqx"},{"task":"We don't attach the invoice any more. Remove the sentence about the PDF, which runs onto the next line.","hint":"d/ works across lines: it deletes up to the match wherever it is.","mode":"python","start":"from shop.emails.render import render_template\n\n\ndef confirmation_email(order):\n    \"\"\"Build the order confirmation email. We used to attach the invoice as\n    a PDF here, but customers download it from their account now. The\n    template itself lives in emails/templates/confirmation.html.\n    \"\"\"\n    return render_template(\"confirmation\", order=order)","startCursor":{"line":0,"ch":0},"paths":[{"keys":["/","We","<CR>","d","/","The","<CR>"],"tier":"idiomatic","technique":"operator-search","core":["operator-search"],"note":"The search finds The on the next line, so d/ deletes the end of this line and the start of that one."}],"target":"from shop.emails.render import render_template\n\n\ndef confirmation_email(order):\n    \"\"\"Build the order confirmation email. The\n    template itself lives in emails/templates/confirmation.html.\n    \"\"\"\n    return render_template(\"confirmation\", order=order)","language":"python","evidence":"guided","canonicalKey":"intermediate.4#2","canonicalFingerprint":"1nkew79"},{"task":"The API sets the content type itself. Delete the <code>Content-Type</code> header.","hint":"dt deletes up to a character on the line and keeps it. The header ends just before the X of the next one.","mode":"python","start":"import httpx as http\nfrom shop.conf import api_settings\n\nBASE = \"https://api.northwind.shop/v2\"\n\n\ndef request(path, **options):\n    \"\"\"Every request sends JSON and the shop's API key.\"\"\"\n    return http.request(url=BASE + path, headers={\"Content-Type\": \"application/json\", \"X-Api-Key\": api_settings.KEY}, **options)","startCursor":{"line":8,"ch":4},"paths":[{"keys":["f","C","d","t","X"],"tier":"idiomatic","technique":"motion:t","core":["motion:t","operator-motion"],"note":"dtX keeps the X, and the quote before Content-Type becomes the quote of X-Api-Key."}],"target":"import httpx as http\nfrom shop.conf import api_settings\n\nBASE = \"https://api.northwind.shop/v2\"\n\n\ndef request(path, **options):\n    \"\"\"Every request sends JSON and the shop's API key.\"\"\"\n    return http.request(url=BASE + path, headers={\"X-Api-Key\": api_settings.KEY}, **options)","language":"python","evidence":"guided","canonicalKey":"intermediate.4#3","canonicalFingerprint":"1w9jo9u"}]},"text":{"id":"intermediate.4","title":"Make search part of an edit","moduleName":"Boundaries and reusable text","tips":"","concept":"<p class=\"lead\">Delete or change text up to a word you can see, and leave lookalike words alone.</p><p><strong>Before this lesson:</strong> Search foundations and operator grammar.</p><p>d/pattern then Enter deletes up to the next match and keeps the match itself, even when the match is on another line. c/ deletes the same text and puts you in Insert mode. When the end is a character on the same line, dt is shorter, and a WORD or two goes with d2W.</p><h3>Example</h3><p>From Remove in “Remove this; keep the note”, d/keep then Enter leaves “keep the note”. c/keep stops at the same place and lets you type new text.</p><p>Use Start over to try again.</p>","teaches":["operator-search","operator-motion","search","search:*"],"introduces":["search","d","c","*","#","e","w"],"constraints":[],"drills":[{"task":"Shorten the note: remove <code>which you can read at any time on the help page, </code>.","hint":"d/ deletes up to a search match and keeps the match. Type the start of the word to stop at, then Enter.","mode":"text/plain","start":"# Payment page\n\nUnder the Pay button:\n\nBy paying you accept our terms, which you can read at any time on the help page, and our privacy policy.","startCursor":{"line":4,"ch":32},"paths":[{"keys":["d","/","and","<CR>"],"tier":"idiomatic","technique":"operator-search","core":["operator-search"],"note":"d/and deletes everything up to the next and, punctuation included, and keeps the and."}],"target":"# Payment page\n\nUnder the Pay button:\n\nBy paying you accept our terms, and our privacy policy.","language":"text","evidence":"guided","canonicalKey":"intermediate.4#0","canonicalFingerprint":"104pghx"},{"task":"We don't leave cards any more. Replace <code>leaves a card and tries again the next working day</code> with <code>takes the parcel to a pickup point</code>.","hint":"c/ deletes up to a search match, even on the next line, and lets you type in its place.","mode":"text/plain","start":"Subject: Your parcel was delivered\n\nHi {{first_name}},\n\nThe carrier marked your parcel as delivered today. If you weren't home, the carrier leaves a card and tries again the next\nworking day, so you don't need to do anything.\n\nNorthwind customer service","startCursor":{"line":0,"ch":0},"paths":[{"keys":["/","lea","<CR>","c","/",", so","<CR>","takes the parcel to a pickup point","<Esc>"],"tier":"idiomatic","technique":"operator:c","core":["operator:c","operator-search"],"note":"c/, so stops just before the comma on the next line, so the rest of the sentence stays."}],"target":"Subject: Your parcel was delivered\n\nHi {{first_name}},\n\nThe carrier marked your parcel as delivered today. If you weren't home, the carrier takes the parcel to a pickup point, so you don't need to do anything.\n\nNorthwind customer service","language":"text","evidence":"guided","canonicalKey":"intermediate.4#1","canonicalFingerprint":"890tqx"},{"task":"We don't attach the invoice any more. Remove the sentence about the PDF, which runs onto the next line.","hint":"d/ works across lines: it deletes up to the match wherever it is.","mode":"text/plain","start":"Subject: Order received\n\nHello {{customer.first_name}},\n\nThanks for your order. We've attached your invoice as\na PDF, and you can also download it from your account. Your\nparcel leaves our warehouse within two working days.\n\nNorthwind","startCursor":{"line":2,"ch":0},"paths":[{"keys":["/","We","<CR>","d","/","You","<CR>"],"tier":"idiomatic","technique":"operator-search","core":["operator-search"],"note":"The search finds Your on the next line, so d/ deletes the end of this line and the start of that one."}],"target":"Subject: Order received\n\nHello {{customer.first_name}},\n\nThanks for your order. Your\nparcel leaves our warehouse within two working days.\n\nNorthwind","language":"text","evidence":"guided","canonicalKey":"intermediate.4#2","canonicalFingerprint":"1nkew79"},{"task":"Debug mode is on by default now. Remove <code>-e DEBUG=1</code> and its space from the command.","hint":"The option and its value are two WORDs, so d2W deletes them with their space.","mode":"text/plain","start":"# Running the shop locally\n\nStart the database first, then the shop:\n\ndocker run --rm -e DEBUG=1 -e SHOP_ENV=staging -p 3000:3000 northwind/shop\n\nOpen http://localhost:3000 when it says it's ready.","startCursor":{"line":4,"ch":0},"paths":[{"keys":["3","W","d","2","W"],"tier":"idiomatic","technique":"count","core":["count","operator-motion"],"note":"Two WORDs with no spaces inside them: d2W is shorter than searching for where they end."}],"target":"# Running the shop locally\n\nStart the database first, then the shop:\n\ndocker run --rm -e SHOP_ENV=staging -p 3000:3000 northwind/shop\n\nOpen http://localhost:3000 when it says it's ready.","language":"text","evidence":"guided","canonicalKey":"intermediate.4#3","canonicalFingerprint":"1w9jo9u"}]}},"concepts":{"javascript":{"lead":"","reminder":"<p class=\"lesson-prereq\"><strong>Before this lesson:</strong> Search foundations and operator grammar.</p>","more":"<details class=\"lesson-more\"><summary>More about this lesson</summary><div class=\"lesson-more-body prose\"><p class=\"lead\">Delete or change text up to a word you can see, and leave lookalike words alone.</p><p>d/pattern then Enter deletes up to the next match and keeps the match itself, even when the match is on another line. c/ deletes the same text and puts you in Insert mode. When the end is a character on the same line, dt is shorter, and a WORD or two goes with d2W.</p><h2 class=\"prose-subhead\">Example</h2><p>From Remove in “Remove this; keep the note”, d/keep then Enter leaves “keep the note”. c/keep stops at the same place and lets you type new text.</p><p>Use Start over to try again.</p></div></details>"},"python":{"lead":"","reminder":"<p class=\"lesson-prereq\"><strong>Before this lesson:</strong> Search foundations and operator grammar.</p>","more":"<details class=\"lesson-more\"><summary>More about this lesson</summary><div class=\"lesson-more-body prose\"><p class=\"lead\">Delete or change text up to a word you can see, and leave lookalike words alone.</p><p>d/pattern then Enter deletes up to the next match and keeps the match itself, even when the match is on another line. c/ deletes the same text and puts you in Insert mode. When the end is a character on the same line, dt is shorter, and a WORD or two goes with d2W.</p><h2 class=\"prose-subhead\">Example</h2><p>From Remove in “Remove this; keep the note”, d/keep then Enter leaves “keep the note”. c/keep stops at the same place and lets you type new text.</p><p>Use Start over to try again.</p></div></details>"},"text":{"lead":"","reminder":"<p class=\"lesson-prereq\"><strong>Before this lesson:</strong> Search foundations and operator grammar.</p>","more":"<details class=\"lesson-more\"><summary>More about this lesson</summary><div class=\"lesson-more-body prose\"><p class=\"lead\">Delete or change text up to a word you can see, and leave lookalike words alone.</p><p>d/pattern then Enter deletes up to the next match and keeps the match itself, even when the match is on another line. c/ deletes the same text and puts you in Insert mode. When the end is a character on the same line, dt is shorter, and a WORD or two goes with d2W.</p><h2 class=\"prose-subhead\">Example</h2><p>From Remove in “Remove this; keep the note”, d/keep then Enter leaves “keep the note”. c/keep stops at the same place and lets you type new text.</p><p>Use Start over to try again.</p></div></details>"}}}