From the course: Learning vi
Unlock the full course today
Join today to access over 22,500 courses taught by industry experts or purchase this course individually.
Using lines and ranges in colon commands - vi Tutorial
From the course: Learning vi
Using lines and ranges in colon commands
Now I'm going to show you one of vi's most powerful and esoteric features, which is that when you use a colon command, you can specify a line or a range of lines upon which the command acts. When you use this feature, you're actually reaching down through the visual interface provided by vi, to the EX line editor that's underneath it. When you use a colon command, you can specify a line, or a range of lines separated by a comma before the command letter. This performs the command on the specified lines. You can specify a line as a number, which means a line number. A dot indicating a current line. A dollar sign meaning the last line of the file, whatever its number is. An apostrophe followed by a letter, which references a mark. You can set a mark in the file by moving the cursor to a line and typing m followed by the letter. So, for example, you type ma, that sets mark a, and then you can use that in a colon command by saying 'a. You can specify a regular expression between slashes…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.