Copy, move, sort
Orders that rearrange the lines: :t copies them to below a line you name (and leaves the jars alone), :m moves them, and :sort lines them up (u drops duplicates, n by number, a range keeps the heading out).
Thursday, 5:30 p.m. Last chores before migration night. The courier list in the docs needs its header repeated at the bottom, as every internal page does; a module has its export default at the top where the linter wants it at the bottom; and the list of courier zones has duplicates and isn't sorted.
Moving lines around is one more kind of order on the slip.
Warm-up from earlier chapters
Two from earlier chapters, from memory, before the new idea. Two wrong tries show the answer.
, to the end of every line that isn't empty., to the end of every line that isn't empty.Copy these to there
:t copies the slip's lines to below the line you name after it (read it as copy to). :t. copies the line you're on to just below itself; :1,2t$ copies lines 1 and 2 to the end of the file; :t0 copies to the very top. Nothing goes in any jar, so your registers stay as they were.
// Internal, do not share.courier 7: Wynwoodcourier 12: Brickell// Internal, do not share.courier 7: Wynwoodcourier 12: Brickell// Internal, do not share.$).The header, again
Three steps. Downtown's line got pasted into the header: cut it with dd, so it's in the jar. Copy the two header lines to the end of the page with one slip, :1,2t$↵. Then put Downtown back under Edgewater with p: the jar still holds it, because :t never touched it. (Copy the header with yy and p instead, and the jar would hold the header.)
This exercise needs a keyboard. Read on, and play it at your computer.
Move these to there
:m moves instead of copying: :m$ sends the line you're on to the bottom, :m0 to the top, :m+1 down past the next line. With a range in front, a whole block moves at once: :'<,'>m0.
Export at the bottom
The export default line goes to the bottom of the file. The cursor is on it: :m$↵.
The first exercise of every lesson is free. Pro unlocks the rest, every track, for good.
See ProThis exercise needs a keyboard. Read on, and play it at your computer.
Line them up
:sort sorts the lines of the range, the whole file if you give none. :sort u also drops lines that appear twice, and :sort n sorts by the first number on each line, so that 9 comes before 10.
wynwoodbrickelledgewaterbrickellbrickelledgewaterwynwoodbrickell only once.Ten before nine?
You send :sort↵ on 10, 9 and 100. In what order are they?
Lists in order
Three lists, three decisions: a plain sort, one with duplicates, and courier ids by number under a heading that has to stay on top. The line under the editor says which is which. (Curious? Sort the last one without a range, look where the heading went, and u.)
Stuck? Show a hint
The first exercise of every lesson is free. Pro unlocks the rest, every track, for good.
See ProThis exercise needs a keyboard. Read on, and play it at your computer.
Rearranging, from memory
Press the keys.