{"schemaVersion":1,"contentVersion":"3.4.0","id":"foundation.5","languages":{"javascript":{"id":"foundation.5","title":"Reach a line or buffer boundary","moduleName":"Editing foundations","tips":"","concept":"<p class=\"lead\">Jump to the start or end of a line, or to the first or last line of the file.</p><p><strong>Before this lesson:</strong> Choose a word destination.</p><p>0 goes to the very first column, ^ to the first character that isn't a space, and $ to the last character. gg goes to the first line and G to the last. Put a number before G to pick a line, so 3G goes to line 3. Press 0 after a line jump when you need the first column.</p><div class=\"pkeys\"><kbd>0</kbd> <kbd>^</kbd> <kbd>$</kbd> <kbd>gg</kbd> <kbd>G</kbd> <kbd>3G</kbd></div><h3>Example</h3><p>On “  review notes”, 0 lands on the first space, ^ on r and $ on s. In a longer file, gg takes you to the first line and 12G to line 12, each to its first character.</p><h4>Worked text</h4><pre class=\"lesson-example\">  // review notes</pre><p>Use Start over to try again.</p>","teaches":["motion:0","motion:^","motion:$","motion:gg","motion:G"],"introduces":["0","^","$","gg","G","count"],"constraints":[],"drills":[{"task":"Put the cursor at the very start of the <code>return</code> line, before its spaces.","hint":"0 goes to the very first column, before the spaces.","mode":"jsx","start":"// Reads the signed-in user from localStorage.\nexport function currentUser() {\n  const saved = localStorage.getItem(\"northwind.user\");\n  return saved ? JSON.parse(saved) : null;\n}","startCursor":{"line":3,"ch":17},"paths":[{"keys":["0"],"tier":"idiomatic","technique":"motion:0","core":["motion:0"],"note":"0 goes to the first column, even on an indented line."}],"kind":"navigate","land":{"line":3,"ch":0},"language":"javascript","evidence":"guided","canonicalKey":"foundation.5#0","canonicalFingerprint":"ixow0f"},{"task":"Put the cursor on <code>throw</code>, at the start of its line.","hint":"^ goes to the first character that isn't a space.","mode":"jsx","start":"import { request } from \"./transport.js\";\n\n// Starts a payment with the provider and returns its checkout URL.\nexport async function startPayment(order) {\n  const payment = await request(\"/payments\", { method: \"POST\", body: { orderId: order.id } });\n  if (!payment.checkoutUrl)\n    throw new Error(`No checkout URL for order ${order.number}`);\n  return payment.checkoutUrl;\n}","startCursor":{"line":6,"ch":41},"paths":[{"keys":["^"],"tier":"idiomatic","technique":"motion:^","core":["motion:^"],"note":"^ skips the indentation."}],"kind":"navigate","land":{"line":6,"ch":4},"language":"javascript","evidence":"guided","canonicalKey":"foundation.5#1","canonicalFingerprint":"a4nnfd"},{"task":"Put the cursor on <code>newCheckout</code>, at the start of line 7.","hint":"A number before G jumps to that line, to its first character.","mode":"jsx","start":"// Feature flags. Turn one off here and the next deploy hides it.\nexport const features = {\n  wishlist: true,\n  giftWrap: false,\n  reviews: true,\n  pickupPoints: true,\n  newCheckout: false,\n  darkMode: true,\n  loyaltyPoints: false,\n};\n\nexport function isOn(name) {\n  return features[name] === true;\n}","startCursor":{"line":12,"ch":24},"paths":[{"keys":["7","G"],"tier":"idiomatic","technique":"count","core":["count","motion:G"],"note":"A line number and G go straight to the start of that line."}],"kind":"navigate","land":{"line":6,"ch":2},"language":"javascript","evidence":"guided","canonicalKey":"foundation.5#2","canonicalFingerprint":"1nye73d"},{"task":"Put the cursor on the first <code>import</code>, at the top of the file.","hint":"gg goes to the first line, wherever you are.","mode":"jsx","start":"import React, { useState } from \"react\";\nimport { useCart } from \"../hooks/useCart.js\";\nimport { startPayment } from \"../api/payments.js\";\nimport { AddressForm } from \"./AddressForm.jsx\";\n\n// The last step: the address, then off to the payment provider.\nexport function Checkout() {\n  const [items] = useCart();\n  const [address, setAddress] = useState(null);\n  async function pay() {\n    window.location.assign(await startPayment({ items, address }));\n  }\n  return <AddressForm value={address} onChange={setAddress} onSubmit={pay} />;\n}","startCursor":{"line":12,"ch":2},"paths":[{"keys":["g","g"],"tier":"idiomatic","technique":"motion:gg","core":["motion:gg"],"note":"gg goes to the first line from anywhere in the file."}],"kind":"navigate","land":{"line":0,"ch":0},"language":"javascript","evidence":"guided","canonicalKey":"foundation.5#3","canonicalFingerprint":"ktv43c"},{"task":"Put the cursor on the <code>;</code> at the end of the file.","hint":"G goes to the last line, wherever you are, and $ to the end of it.","mode":"jsx","start":"import { useUser } from \"../hooks/useUser.js\";\nimport { OrderList } from \"../components/OrderList.jsx\";\n\n// Your details and your last orders.\nfunction Account() {\n  const user = useUser();\n  if (!user) return <p>Sign in to see your orders.</p>;\n  return (\n    <main>\n      <h1>Hi {user.firstName}</h1>\n      <OrderList customerId={user.id} limit={10} />\n    </main>\n  );\n}\nexport default Account;","startCursor":{"line":9,"ch":6},"paths":[{"keys":["G","$"],"tier":"idiomatic","technique":"motion:G","core":["motion:G","motion:$"],"note":"G goes to the last line from anywhere in the file, and $ to its end."}],"kind":"navigate","land":{"line":14,"ch":22},"language":"javascript","evidence":"guided","canonicalKey":"foundation.5#4","canonicalFingerprint":"gn8dd7"}]},"python":{"id":"foundation.5","title":"Reach a line or buffer boundary","moduleName":"Editing foundations","tips":"","concept":"<p class=\"lead\">Jump to the start or end of a line, or to the first or last line of the file.</p><p><strong>Before this lesson:</strong> Choose a word destination.</p><p>0 goes to the very first column, ^ to the first character that isn't a space, and $ to the last character. gg goes to the first line and G to the last. Put a number before G to pick a line, so 3G goes to line 3. Press 0 after a line jump when you need the first column.</p><div class=\"pkeys\"><kbd>0</kbd> <kbd>^</kbd> <kbd>$</kbd> <kbd>gg</kbd> <kbd>G</kbd> <kbd>3G</kbd></div><h3>Example</h3><p>On “  review notes”, 0 lands on the first space, ^ on r and $ on s. In a longer file, gg takes you to the first line and 12G to line 12, each to its first character.</p><h4>Worked text</h4><pre class=\"lesson-example\">  # review notes</pre><p>Use Start over to try again.</p>","teaches":["motion:0","motion:^","motion:$","motion:gg","motion:G"],"introduces":["0","^","$","gg","G","count"],"constraints":[],"drills":[{"task":"Put the cursor at the very start of the <code>return</code> line, before its spaces.","hint":"0 goes to the very first column, before the spaces.","mode":"python","start":"def current_user(request):\n    \"\"\"The signed-in user, or None.\"\"\"\n    user_id = request.session.get(\"user_id\")\n    return User.objects.filter(pk=user_id).first() if user_id else None","startCursor":{"line":3,"ch":42},"paths":[{"keys":["0"],"tier":"idiomatic","technique":"motion:0","core":["motion:0"],"note":"0 goes to the first column, even on an indented line."}],"kind":"navigate","land":{"line":3,"ch":0},"language":"python","evidence":"guided","canonicalKey":"foundation.5#0","canonicalFingerprint":"ixow0f"},{"task":"Put the cursor on <code>raise</code>, at the start of its line.","hint":"^ goes to the first character that isn't a space.","mode":"python","start":"from shop.payments.provider import provider\n\n\ndef start_payment(order):\n    \"\"\"Starts a payment with the provider and returns its checkout URL.\"\"\"\n    payment = provider.create_payment(order_id=order.id, amount=order.total)\n    if not payment.checkout_url:\n        raise ValueError(f\"No checkout URL for order {order.number}\")\n    return payment.checkout_url","startCursor":{"line":7,"ch":47},"paths":[{"keys":["^"],"tier":"idiomatic","technique":"motion:^","core":["motion:^"],"note":"^ skips the indentation."}],"kind":"navigate","land":{"line":7,"ch":8},"language":"python","evidence":"guided","canonicalKey":"foundation.5#1","canonicalFingerprint":"a4nnfd"},{"task":"Put the cursor on <code>NEW_CHECKOUT</code>, at the start of line 6.","hint":"A number before G jumps to that line, to its first character.","mode":"python","start":"\"\"\"Feature flags. Turn one off here and the next deploy hides it.\"\"\"\nWISHLIST = True\nGIFT_WRAP = False\nREVIEWS = True\nPICKUP_POINTS = True\nNEW_CHECKOUT = False\nDARK_MODE = True\nLOYALTY_POINTS = False\n\n\ndef is_on(name):\n    return globals().get(name) is True","startCursor":{"line":11,"ch":34},"paths":[{"keys":["6","G"],"tier":"idiomatic","technique":"count","core":["count","motion:G"],"note":"A line number and G go straight to the start of that line."}],"kind":"navigate","land":{"line":5,"ch":0},"language":"python","evidence":"guided","canonicalKey":"foundation.5#2","canonicalFingerprint":"1nye73d"},{"task":"Put the cursor on the first <code>from</code>, at the top of the file.","hint":"gg goes to the first line, wherever you are.","mode":"python","start":"from django.shortcuts import redirect, render\n\nfrom shop.cart.store import load_cart\nfrom shop.payments.start import start_payment\n\n\ndef checkout(request):\n    \"\"\"The last step: the address, then off to the payment provider.\"\"\"\n    cart = load_cart(request.session)\n    if request.method != \"POST\":\n        return render(request, \"checkout.html\", {\"cart\": cart})\n    try:\n        return redirect(start_payment(cart.to_order(request.POST)))\n    except ValueError as error:\n        return render(request, \"checkout.html\", {\"cart\": cart, \"error\": error})","startCursor":{"line":13,"ch":4},"paths":[{"keys":["g","g"],"tier":"idiomatic","technique":"motion:gg","core":["motion:gg"],"note":"gg goes to the first line from anywhere in the file."}],"kind":"navigate","land":{"line":0,"ch":0},"language":"python","evidence":"guided","canonicalKey":"foundation.5#3","canonicalFingerprint":"ktv43c"},{"task":"Put the cursor on the <code>)</code> at the end of the file.","hint":"G goes to the last line, wherever you are, and $ to the end of it.","mode":"python","start":"from django.template.response import TemplateResponse\nfrom django.views.decorators.http import require_GET\n\nfrom shop.orders.queries import last_orders\n\n\n@require_GET\ndef account(request):\n    \"\"\"Your details and your last orders.\"\"\"\n    orders = last_orders(request.user, limit=10)\n    context = {\"user\": request.user, \"orders\": orders}\n    return TemplateResponse(request, \"account.html\", context)","startCursor":{"line":7,"ch":0},"paths":[{"keys":["G","$"],"tier":"idiomatic","technique":"motion:G","core":["motion:G","motion:$"],"note":"G goes to the last line from anywhere in the file, and $ to its end."}],"kind":"navigate","land":{"line":11,"ch":60},"language":"python","evidence":"guided","canonicalKey":"foundation.5#4","canonicalFingerprint":"gn8dd7"}]},"text":{"id":"foundation.5","title":"Reach a line or buffer boundary","moduleName":"Editing foundations","tips":"","concept":"<p class=\"lead\">Jump to the start or end of a line, or to the first or last line of the file.</p><p><strong>Before this lesson:</strong> Choose a word destination.</p><p>0 goes to the very first column, ^ to the first character that isn't a space, and $ to the last character. gg goes to the first line and G to the last. Put a number before G to pick a line, so 3G goes to line 3. Press 0 after a line jump when you need the first column.</p><div class=\"pkeys\"><kbd>0</kbd> <kbd>^</kbd> <kbd>$</kbd> <kbd>gg</kbd> <kbd>G</kbd> <kbd>3G</kbd></div><h3>Example</h3><p>On “  review notes”, 0 lands on the first space, ^ on r and $ on s. In a longer file, gg takes you to the first line and 12G to line 12, each to its first character.</p><h4>Worked text</h4><pre class=\"lesson-example\">  review notes</pre><p>Use Start over to try again.</p>","teaches":["motion:0","motion:^","motion:$","motion:gg","motion:G"],"introduces":["0","^","$","gg","G","count"],"constraints":[],"drills":[{"task":"Put the cursor at the very start of the list item, before its spaces.","hint":"0 goes to the very first column, before the spaces.","mode":"text/plain","start":"## Writing for the shop\n\n- Use whole sentences.\n  - Say \"you\", and keep it short.\n- Prices always have a currency.","startCursor":{"line":3,"ch":19},"paths":[{"keys":["0"],"tier":"idiomatic","technique":"motion:0","core":["motion:0"],"note":"0 goes to the first column, even on an indented line."}],"kind":"navigate","land":{"line":3,"ch":0},"language":"text","evidence":"guided","canonicalKey":"foundation.5#0","canonicalFingerprint":"ixow0f"},{"task":"Put the cursor on <code>npm</code>, at the start of its line.","hint":"^ goes to the first character that isn't a space.","mode":"text/plain","start":"# Deploying the shop\n\nDeploys run from the main branch. To deploy by hand:\n\n    git pull origin main\n    npm run deploy -- --site production\n    open https://northwind.shop to check it\n\nTell #ops when you're done.","startCursor":{"line":5,"ch":29},"paths":[{"keys":["^"],"tier":"idiomatic","technique":"motion:^","core":["motion:^"],"note":"^ skips the indentation."}],"kind":"navigate","land":{"line":5,"ch":4},"language":"text","evidence":"guided","canonicalKey":"foundation.5#1","canonicalFingerprint":"a4nnfd"},{"task":"Put the cursor at the start of line 7, on the <code>3</code> of the restart step.","hint":"A number before G jumps to that line, to its first character.","mode":"text/plain","start":"# When the shop is down\n\nDon't panic, and don't deploy anything new while you look.\n\n1. Check the status page and the #ops-alerts channel.\n2. Look at the last deploy. If it went out in the last hour, roll it back.\n3. Restart the web servers from the hosting dashboard.\n4. If the database is the problem, call whoever is on call for it.\n\nWrite down what you did and when, with the times from the alerts.\nWe go through it together the next working day, without blaming anyone.\nThe status page should say what's happening within fifteen minutes.","startCursor":{"line":11,"ch":51},"paths":[{"keys":["7","G"],"tier":"idiomatic","technique":"count","core":["count","motion:G"],"note":"A line number and G go straight to the start of that line."}],"kind":"navigate","land":{"line":6,"ch":0},"language":"text","evidence":"guided","canonicalKey":"foundation.5#2","canonicalFingerprint":"1nye73d"},{"task":"Put the cursor on the <code>#</code> of the title, at the top of the file.","hint":"gg goes to the first line, wherever you are.","mode":"text/plain","start":"# Changelog\n\n## 4.2.0, 12 November\n\n- Faster search on the orders page.\n- Order emails show the delivery date.\n- Fixed totals that were off by a cent for some discounts.\n\n## 4.1.0, 29 October\n\n- Pay with iDEAL and Bancontact.\n- The cart remembers what you added on another device.\n- Product pages load their photos as you scroll.","startCursor":{"line":12,"ch":16},"paths":[{"keys":["g","g"],"tier":"idiomatic","technique":"motion:gg","core":["motion:gg"],"note":"gg goes to the first line from anywhere in the file."}],"kind":"navigate","land":{"line":0,"ch":0},"language":"text","evidence":"guided","canonicalKey":"foundation.5#3","canonicalFingerprint":"ktv43c"},{"task":"Put the cursor on the full stop at the end of the file.","hint":"G goes to the last line, wherever you are, and $ to the end of it.","mode":"text/plain","start":"# Support rota\n\nSomeone from the team answers the help desk every weekday from 9:00 to 17:00.\nSwap shifts in the #support channel, and update the calendar.\n\nThis month:\n- Monday: Dana\n- Tuesday: Kemal\n- Wednesday: Priya\n- Thursday: Ines\n- Friday: Tom\n\nQuestions about the rota go to Priya.","startCursor":{"line":2,"ch":0},"paths":[{"keys":["G","$"],"tier":"idiomatic","technique":"motion:G","core":["motion:G","motion:$"],"note":"G goes to the last line from anywhere in the file, and $ to its end."}],"kind":"navigate","land":{"line":12,"ch":36},"language":"text","evidence":"guided","canonicalKey":"foundation.5#4","canonicalFingerprint":"gn8dd7"}]}},"concepts":{"javascript":{"lead":"","reminder":"<p class=\"lesson-prereq\"><strong>Before this lesson:</strong> Choose a word destination.</p>","more":"<details class=\"lesson-more\"><summary>More about this lesson</summary><div class=\"lesson-more-body prose\"><p class=\"lead\">Jump to the start or end of a line, or to the first or last line of the file.</p><p>0 goes to the very first column, ^ to the first character that isn't a space, and $ to the last character. gg goes to the first line and G to the last. Put a number before G to pick a line, so 3G goes to line 3. Press 0 after a line jump when you need the first column.</p><h2 class=\"prose-subhead\">Example</h2><p>On “  review notes”, 0 lands on the first space, ^ on r and $ on s. In a longer file, gg takes you to the first line and 12G to line 12, each to its first character.</p><p>Use Start over to try again.</p></div></details>"},"python":{"lead":"","reminder":"<p class=\"lesson-prereq\"><strong>Before this lesson:</strong> Choose a word destination.</p>","more":"<details class=\"lesson-more\"><summary>More about this lesson</summary><div class=\"lesson-more-body prose\"><p class=\"lead\">Jump to the start or end of a line, or to the first or last line of the file.</p><p>0 goes to the very first column, ^ to the first character that isn't a space, and $ to the last character. gg goes to the first line and G to the last. Put a number before G to pick a line, so 3G goes to line 3. Press 0 after a line jump when you need the first column.</p><h2 class=\"prose-subhead\">Example</h2><p>On “  review notes”, 0 lands on the first space, ^ on r and $ on s. In a longer file, gg takes you to the first line and 12G to line 12, each to its first character.</p><p>Use Start over to try again.</p></div></details>"},"text":{"lead":"","reminder":"<p class=\"lesson-prereq\"><strong>Before this lesson:</strong> Choose a word destination.</p>","more":"<details class=\"lesson-more\"><summary>More about this lesson</summary><div class=\"lesson-more-body prose\"><p class=\"lead\">Jump to the start or end of a line, or to the first or last line of the file.</p><p>0 goes to the very first column, ^ to the first character that isn't a space, and $ to the last character. gg goes to the first line and G to the last. Put a number before G to pick a line, so 3G goes to line 3. Press 0 after a line jump when you need the first column.</p><h2 class=\"prose-subhead\">Example</h2><p>On “  review notes”, 0 lands on the first space, ^ on r and $ on s. In a longer file, gg takes you to the first line and 12G to line 12, each to its first character.</p><p>Use Start over to try again.</p></div></details>"}}}