Checkpoint: rearrange lines in real files
The technique
dd then p swaps two lines. yyp copies a line below itself, so you only change the part that differs.
Keys in this lesson
- dd
- Delete the line.
- p
- Put after the cursor, or below the line.
- P
- Put before the cursor, or above the line.
- yy
- Copy the line.
Before this lesson: Copying and moving lines, and the module's repeats.
More about this lesson
Move, copy and delete whole lines in each of three real files, with one more change alongside.
You choose the commands here. dd and p move a line, P puts it above, and yyp copies one so you can change the copy. Each file also has a change that the dot, cgn or Ctrl-v makes quicker. Getting it right matters more than the number of keys.
Example
Before you finish in Normal mode, check the order of the lines and the changes one at a time.
Try without hints first. Open help if you need it.
Guides on this topic
Exercise 1 of 3
0keys
par 45Put /orders above /orders/:id, and add a /returns route below /orders, like it, with the Returns page. The admin pages aren't ready, so comment out their three routes. You can use any commands.
Make it look like this
import { Account, AdminOrders, AdminProducts, AdminUsers, Home, NotFound, OrderDetail, Orders, Returns } from "./pages"; // React Router tries these in order and uses the first that matches. export const routes = [ { path: "/", element: <Home /> }, { path: "/orders", element: <Orders /> }, { path: "/returns", element: <Returns /> }, { path: "/orders/:id", element: <OrderDetail /> }, { path: "/account", element: <Account /> }, // { path: "/admin/orders", element: <AdminOrders /> }, // { path: "/admin/products", element: <AdminProducts /> }, // { path: "/admin/users", element: <AdminUsers /> }, { path: "*", element: <NotFound /> }, ];