01 / 08
When you do not know the line number
By now vi is fairly usable. But one situation still leaves you stuck.
in a 300-line settings filemend the line that says "port"You do not know which line. 3G is no use without the number.
You could press j and look, but 300 lines will not do.
So you search by contents.
/port -> ⏎You jump to the line that says port. That is the star of this lesson.
Rather like grep, you may think. Just so.
grep port settings.conf which line has it (chapter 5)/port inside vi jump to that lineThe business of searching is the same; grep shows you, and vi takes you there.
There is one more thing this lesson does.
:%s/80/8080/gReplace them all. Rather like doing sed from inside vi.
sed 's/80/8080/g' file makes output (chapter 5)the :%s/80/8080/g of vi mends the file you have openHere is what this lesson gives you.
/word n search down, to the next?word search up:s replace in this line:%s replace in every lineAble to search, and vi is complete. Only the test of skill is left.