01 / 08
Do not type a similar line twice
Look at a settings file and you notice similar lines in a row.
host web1host web2host web3All three differ by one character at the end. Typing that three times is a waste.
write one linecopy itpaste itmend one characterGrow it without typing it again. That is what this lesson does.
Only two commands are used.
yy take the line you are on into store (copy)p paste what is in storeyy is yank, p is put.
And there is another important use.
dd remove a line (it goes into store as well)p paste it somewhere elseRemove and paste, and the line has moved.
dd -> move -> p move a lineCut and paste, an operation you know well. vi has it properly.
Here is what this lesson gives you.
yy p grow linesdd p move linesx p swap charactersP paste above3yy copy three lines togetherLess typing is what this lesson is worth. When you notice yourself typing the same thing twice, think whether it could be copied.