{"schemaVersion":1,"contentVersion":"3.4.0","id":"intermediate.8","languages":{"javascript":{"id":"intermediate.8","title":"Use paragraph boundaries","moduleName":"Boundaries and reusable text","tips":"","concept":"<p class=\"lead\">Edit paragraphs, which in Vim are just text between blank lines.</p><p><strong>Before this lesson:</strong> Words and operators.</p><p>Vim splits paragraphs at blank lines. ip is the paragraph's text and ap also takes the blank lines after it. } moves to the blank line after the paragraph and { to the one before it. Braces and indentation in code don't count: a function or a group of imports is a paragraph when blank lines surround it.</p><h3>Example</h3><p>With two notes and a blank line between them, dip deletes the current note and keeps the blank line. dap deletes the blank line too.</p><p>Use Start over to try again.</p>","teaches":["motion:}","textobject:ap","textobject:ip"],"introduces":["}","{","textobject"],"constraints":[],"drills":[{"task":"Nothing calls <code>legacyTotal</code> any more. Delete the function and the blank line after it.","hint":"dap deletes the paragraph the cursor is in, and the blank line after it.","mode":"jsx","start":"import { sum } from \"../lib/math\";\n\nexport function itemsTotal(cart) {\n  return sum(cart.items.map((item) => item.cents * item.quantity));\n}\n\nexport function legacyTotal(cart) {\n  const raw = cart.items.reduce((acc, item) => acc + item.price, 0);\n  return Math.round(raw * 100);\n}\n\nexport function shippingFor(cart) {\n  return itemsTotal(cart) >= 5000 ? 0 : 495;\n}","startCursor":{"line":7,"ch":2},"paths":[{"keys":["d","a","p"],"tier":"idiomatic","technique":"textobject:ap","core":["textobject:ap"],"note":"To Vim the function is a paragraph: lines with no blank line between them."}],"target":"import { sum } from \"../lib/math\";\n\nexport function itemsTotal(cart) {\n  return sum(cart.items.map((item) => item.cents * item.quantity));\n}\n\nexport function shippingFor(cart) {\n  return itemsTotal(cart) >= 5000 ? 0 : 495;\n}","language":"javascript","evidence":"guided","canonicalKey":"intermediate.8#0","canonicalFingerprint":"15u8acw"},{"task":"The three security checks should run before the body is read. Move their lines up below <code>helmet</code>, into the first block.","hint":"dip deletes the paragraph's lines but not the blank line after it, so p puts just those lines.","mode":"jsx","start":"import express from \"express\";\nimport { security } from \"./security\";\n\nexport const app = express();\napp.use(security.helmet());\napp.use(express.json());\n\napp.use(security.cors());\napp.use(security.rateLimit());\napp.use(security.csrf());\n\napp.listen(process.env.PORT);","startCursor":{"line":8,"ch":0},"paths":[{"keys":["d","i","p","5","G","p","}","d","d"],"tier":"idiomatic","technique":"textobject:ip","core":["textobject:ip"],"note":"dip leaves two blank lines behind, and } takes you to them, so dd tidies up."}],"target":"import express from \"express\";\nimport { security } from \"./security\";\n\nexport const app = express();\napp.use(security.helmet());\napp.use(security.cors());\napp.use(security.rateLimit());\napp.use(security.csrf());\napp.use(express.json());\n\napp.listen(process.env.PORT);","language":"javascript","evidence":"guided","canonicalKey":"intermediate.8#1","canonicalFingerprint":"10u3mhb"},{"task":"Add <code>import { analytics } from \"./analytics\";</code> at the end of the first group of imports.","hint":"} jumps to the blank line after the paragraph, and O opens a line above it.","mode":"jsx","start":"import { createApp } from \"./app\";\nimport { router } from \"./router\";\nimport { store } from \"./store\";\nimport { i18n } from \"./i18n\";\n\nimport \"./styles/reset.css\";\nimport \"./styles/theme.css\";\n\ncreateApp({ router, store, i18n }).mount(\"#app\");","startCursor":{"line":0,"ch":0},"paths":[{"keys":["}","O","import { analytics } from \"./analytics\";","<Esc>"],"tier":"idiomatic","technique":"motion:}","core":["motion:}"],"note":"} goes to the end of the paragraph without counting lines."}],"target":"import { createApp } from \"./app\";\nimport { router } from \"./router\";\nimport { store } from \"./store\";\nimport { i18n } from \"./i18n\";\nimport { analytics } from \"./analytics\";\n\nimport \"./styles/reset.css\";\nimport \"./styles/theme.css\";\n\ncreateApp({ router, store, i18n }).mount(\"#app\");","language":"javascript","evidence":"guided","canonicalKey":"intermediate.8#2","canonicalFingerprint":"i5yac8"},{"task":"Add <code>import { authRouter } from \"./routes/auth\";</code> at the start of the routes' imports.","hint":"{ jumps to the blank line before the paragraph, and o opens a line below it.","mode":"jsx","start":"import Koa from \"koa\";\nimport helmet from \"koa-helmet\";\n\nimport { ordersRouter } from \"./routes/orders\";\nimport { cartRouter } from \"./routes/cart\";\nimport { healthRouter } from \"./routes/health\";\n\nconst server = new Koa();\nserver.use(helmet());\nserver.use(ordersRouter.routes());","startCursor":{"line":5,"ch":0},"paths":[{"keys":["{","o","import { authRouter } from \"./routes/auth\";","<Esc>"],"tier":"idiomatic","technique":"motion:{","core":["motion:{"],"note":"{ goes back to the start of the paragraph without counting lines."}],"target":"import Koa from \"koa\";\nimport helmet from \"koa-helmet\";\n\nimport { authRouter } from \"./routes/auth\";\nimport { ordersRouter } from \"./routes/orders\";\nimport { cartRouter } from \"./routes/cart\";\nimport { healthRouter } from \"./routes/health\";\n\nconst server = new Koa();\nserver.use(helmet());\nserver.use(ordersRouter.routes());","language":"javascript","evidence":"guided","canonicalKey":"intermediate.8#3","canonicalFingerprint":"768kgm"}]},"python":{"id":"intermediate.8","title":"Use paragraph boundaries","moduleName":"Boundaries and reusable text","tips":"","concept":"<p class=\"lead\">Edit paragraphs, which in Vim are just text between blank lines.</p><p><strong>Before this lesson:</strong> Words and operators.</p><p>Vim splits paragraphs at blank lines. ip is the paragraph's text and ap also takes the blank lines after it. } moves to the blank line after the paragraph and { to the one before it. Braces and indentation in code don't count: a function or a group of imports is a paragraph when blank lines surround it.</p><h3>Example</h3><p>With two notes and a blank line between them, dip deletes the current note and keeps the blank line. dap deletes the blank line too.</p><p>Use Start over to try again.</p>","teaches":["motion:}","textobject:ap","textobject:ip"],"introduces":["}","{","textobject"],"constraints":[],"drills":[{"task":"Nothing calls <code>legacy_total</code> any more. Delete the function and the blank lines after it.","hint":"dap deletes the paragraph the cursor is in, and the blank lines after it.","mode":"python","start":"from shop.lib.math import money_sum\n\n\ndef items_total(cart):\n    return money_sum(item.price * item.quantity for item in cart.items)\n\n\ndef legacy_total(cart):\n    raw = sum(item.price for item in cart.items)\n    return round(raw * 100)\n\n\ndef shipping_for(cart):\n    return 0 if items_total(cart) >= 50 else 4.95","startCursor":{"line":8,"ch":4},"paths":[{"keys":["d","a","p"],"tier":"idiomatic","technique":"textobject:ap","core":["textobject:ap"],"note":"To Vim the function is a paragraph: lines with no blank line between them. ap takes both blank lines after it."}],"target":"from shop.lib.math import money_sum\n\n\ndef items_total(cart):\n    return money_sum(item.price * item.quantity for item in cart.items)\n\n\ndef shipping_for(cart):\n    return 0 if items_total(cart) >= 50 else 4.95","language":"python","evidence":"guided","canonicalKey":"intermediate.8#0","canonicalFingerprint":"15u8acw"},{"task":"Delete the three old SMTP settings between the functions. PEP 8 wants two blank lines between the functions after that.","hint":"dip deletes the paragraph's lines and keeps the blank lines on both sides.","mode":"python","start":"from shop.emails.client import mail_client\n\n\ndef email_receipt(order):\n    mail_client.send(\"receipt\", to=order.customer.email, order=order)\n\nLEGACY_SMTP_HOST = \"smtp.old-provider.example\"\nLEGACY_SMTP_PORT = 2525\nLEGACY_SMTP_TLS = False\n\ndef email_refund_notice(order):\n    mail_client.send(\"refund\", to=order.customer.email, order=order)","startCursor":{"line":10,"ch":0},"paths":[{"keys":["2","k","d","i","p"],"tier":"idiomatic","technique":"textobject:ip","core":["textobject:ip"],"note":"dip keeps the blank line above and below, which makes the two PEP 8 wants. dap would leave one."}],"target":"from shop.emails.client import mail_client\n\n\ndef email_receipt(order):\n    mail_client.send(\"receipt\", to=order.customer.email, order=order)\n\n\ndef email_refund_notice(order):\n    mail_client.send(\"refund\", to=order.customer.email, order=order)","language":"python","evidence":"guided","canonicalKey":"intermediate.8#1","canonicalFingerprint":"10u3mhb"},{"task":"Add <code>from shop.analytics import urls as analytics_urls</code> at the end of the first group of imports.","hint":"} jumps to the blank line after the paragraph, and O opens a line above it.","mode":"python","start":"from shop.cart import urls as cart_urls\nfrom shop.orders import urls as order_urls\nfrom shop.accounts import urls as account_urls\nfrom shop.search import urls as search_urls\n\nfrom django.contrib import admin\nfrom django.urls import include, path\n\nurlpatterns = [path(\"admin/\", admin.site.urls), path(\"cart/\", include(cart_urls))]","startCursor":{"line":0,"ch":0},"paths":[{"keys":["}","O","from shop.analytics import urls as analytics_urls","<Esc>"],"tier":"idiomatic","technique":"motion:}","core":["motion:}"],"note":"} goes to the end of the paragraph without counting lines."}],"target":"from shop.cart import urls as cart_urls\nfrom shop.orders import urls as order_urls\nfrom shop.accounts import urls as account_urls\nfrom shop.search import urls as search_urls\nfrom shop.analytics import urls as analytics_urls\n\nfrom django.contrib import admin\nfrom django.urls import include, path\n\nurlpatterns = [path(\"admin/\", admin.site.urls), path(\"cart/\", include(cart_urls))]","language":"python","evidence":"guided","canonicalKey":"intermediate.8#2","canonicalFingerprint":"i5yac8"},{"task":"Add <code>from shop.routes.auth import auth_router</code> at the start of the routes' imports.","hint":"{ jumps to the blank line before the paragraph, and o opens a line below it.","mode":"python","start":"from fastapi import FastAPI\nfrom fastapi.middleware.gzip import GZipMiddleware\n\nfrom shop.routes.orders import orders_router\nfrom shop.routes.cart import cart_router\nfrom shop.routes.health import health_router\n\napi = FastAPI(title=\"Northwind shop\")\napi.add_middleware(GZipMiddleware)\napi.include_router(orders_router)","startCursor":{"line":5,"ch":0},"paths":[{"keys":["{","o","from shop.routes.auth import auth_router","<Esc>"],"tier":"idiomatic","technique":"motion:{","core":["motion:{"],"note":"{ goes back to the start of the paragraph without counting lines."}],"target":"from fastapi import FastAPI\nfrom fastapi.middleware.gzip import GZipMiddleware\n\nfrom shop.routes.auth import auth_router\nfrom shop.routes.orders import orders_router\nfrom shop.routes.cart import cart_router\nfrom shop.routes.health import health_router\n\napi = FastAPI(title=\"Northwind shop\")\napi.add_middleware(GZipMiddleware)\napi.include_router(orders_router)","language":"python","evidence":"guided","canonicalKey":"intermediate.8#3","canonicalFingerprint":"768kgm"}]},"text":{"id":"intermediate.8","title":"Use paragraph boundaries","moduleName":"Boundaries and reusable text","tips":"","concept":"<p class=\"lead\">Edit paragraphs, which in Vim are just text between blank lines.</p><p><strong>Before this lesson:</strong> Words and operators.</p><p>Vim splits paragraphs at blank lines. ip is the paragraph's text and ap also takes the blank lines after it. } moves to the blank line after the paragraph and { to the one before it. Braces and indentation in code don't count: a function or a group of imports is a paragraph when blank lines surround it.</p><h3>Example</h3><p>With two notes and a blank line between them, dip deletes the current note and keeps the blank line. dap deletes the blank line too.</p><p>Use Start over to try again.</p>","teaches":["motion:}","textobject:ap","textobject:ip"],"introduces":["}","{","textobject"],"constraints":[],"drills":[{"task":"We don't have a phone line any more. Delete the paragraph about it and the blank line after it.","hint":"dap deletes the paragraph the cursor is in, and the blank line after it.","mode":"text/plain","start":"# Questions\n\nMost answers are in your account, under Orders.\n\nYou can also call us on weekdays, from 9:00\nto 17:00. Expect a short wait on Mondays,\nwhen most people call about the weekend.\n\nEmail us at help@northwind.shop for anything else.","startCursor":{"line":5,"ch":0},"paths":[{"keys":["d","a","p"],"tier":"idiomatic","technique":"textobject:ap","core":["textobject:ap"],"note":"To Vim a paragraph is the lines between blank lines, however the sentences wrap."}],"target":"# Questions\n\nMost answers are in your account, under Orders.\n\nEmail us at help@northwind.shop for anything else.","language":"text","evidence":"guided","canonicalKey":"intermediate.8#0","canonicalFingerprint":"15u8acw"},{"task":"The three checks belong before the deploy. Move their lines up below <code>Run the tests.</code>, into the first group.","hint":"dip deletes the paragraph's lines but not the blank line after it, so p puts just those lines.","mode":"text/plain","start":"## Before the release\n- Run the tests.\n- Deploy to production.\n\n- Check the payment provider's status page.\n- Let support know a release is coming.\n- Pause the marketing emails.\n\n## After the release","startCursor":{"line":5,"ch":0},"paths":[{"keys":["d","i","p","2","G","p","}","d","d"],"tier":"idiomatic","technique":"textobject:ip","core":["textobject:ip"],"note":"dip leaves two blank lines behind, and } takes you to them, so dd tidies up."}],"target":"## Before the release\n- Run the tests.\n- Check the payment provider's status page.\n- Let support know a release is coming.\n- Pause the marketing emails.\n- Deploy to production.\n\n## After the release","language":"text","evidence":"guided","canonicalKey":"intermediate.8#1","canonicalFingerprint":"10u3mhb"},{"task":"Add <code>- Check the address label.</code> at the end of the packing list.","hint":"} jumps to the blank line after the paragraph, and O opens a line above it.","mode":"text/plain","start":"# Packing an order\n- Print the packing slip.\n- Pick the items from the shelves.\n- Wrap anything fragile.\n- Tape the box shut.\n\nHand the box to the carrier before 16:00.","startCursor":{"line":0,"ch":0},"paths":[{"keys":["}","O","- Check the address label.","<Esc>"],"tier":"idiomatic","technique":"motion:}","core":["motion:}"],"note":"} goes to the end of the paragraph without counting lines."}],"target":"# Packing an order\n- Print the packing slip.\n- Pick the items from the shelves.\n- Wrap anything fragile.\n- Tape the box shut.\n- Check the address label.\n\nHand the box to the carrier before 16:00.","language":"text","evidence":"guided","canonicalKey":"intermediate.8#2","canonicalFingerprint":"i5yac8"},{"task":"Add <code>- Look up the order in the admin.</code> as the first step for a missing parcel.","hint":"{ jumps to the blank line before the paragraph, and o opens a line below it.","mode":"text/plain","start":"# Support steps\n\nA customer says their parcel is missing:\n\n- Check the tracking page.\n- Ask the carrier for a photo of the delivery.\n- Offer a refund or a new parcel.\n\nWrite down what you did in the ticket.","startCursor":{"line":6,"ch":0},"paths":[{"keys":["{","o","- Look up the order in the admin.","<Esc>"],"tier":"idiomatic","technique":"motion:{","core":["motion:{"],"note":"{ goes back to the start of the paragraph without counting lines."}],"target":"# Support steps\n\nA customer says their parcel is missing:\n\n- Look up the order in the admin.\n- Check the tracking page.\n- Ask the carrier for a photo of the delivery.\n- Offer a refund or a new parcel.\n\nWrite down what you did in the ticket.","language":"text","evidence":"guided","canonicalKey":"intermediate.8#3","canonicalFingerprint":"768kgm"}]}},"concepts":{"javascript":{"lead":"","reminder":"<p class=\"lesson-prereq\"><strong>Before this lesson:</strong> Words and operators.</p>","more":"<details class=\"lesson-more\"><summary>More about this lesson</summary><div class=\"lesson-more-body prose\"><p class=\"lead\">Edit paragraphs, which in Vim are just text between blank lines.</p><p>Vim splits paragraphs at blank lines. ip is the paragraph's text and ap also takes the blank lines after it. } moves to the blank line after the paragraph and { to the one before it. Braces and indentation in code don't count: a function or a group of imports is a paragraph when blank lines surround it.</p><h2 class=\"prose-subhead\">Example</h2><p>With two notes and a blank line between them, dip deletes the current note and keeps the blank line. dap deletes the blank line too.</p><p>Use Start over to try again.</p></div></details>"},"python":{"lead":"","reminder":"<p class=\"lesson-prereq\"><strong>Before this lesson:</strong> Words and operators.</p>","more":"<details class=\"lesson-more\"><summary>More about this lesson</summary><div class=\"lesson-more-body prose\"><p class=\"lead\">Edit paragraphs, which in Vim are just text between blank lines.</p><p>Vim splits paragraphs at blank lines. ip is the paragraph's text and ap also takes the blank lines after it. } moves to the blank line after the paragraph and { to the one before it. Braces and indentation in code don't count: a function or a group of imports is a paragraph when blank lines surround it.</p><h2 class=\"prose-subhead\">Example</h2><p>With two notes and a blank line between them, dip deletes the current note and keeps the blank line. dap deletes the blank line too.</p><p>Use Start over to try again.</p></div></details>"},"text":{"lead":"","reminder":"<p class=\"lesson-prereq\"><strong>Before this lesson:</strong> Words and operators.</p>","more":"<details class=\"lesson-more\"><summary>More about this lesson</summary><div class=\"lesson-more-body prose\"><p class=\"lead\">Edit paragraphs, which in Vim are just text between blank lines.</p><p>Vim splits paragraphs at blank lines. ip is the paragraph's text and ap also takes the blank lines after it. } moves to the blank line after the paragraph and { to the one before it. Braces and indentation in code don't count: a function or a group of imports is a paragraph when blank lines surround it.</p><h2 class=\"prose-subhead\">Example</h2><p>With two notes and a blank line between them, dip deletes the current note and keeps the blank line. dap deletes the blank line too.</p><p>Use Start over to try again.</p></div></details>"}}}