October 2015
Intermediate to advanced
356 pages
7h 54m
English
| Tip 28 | Execute a Command on One or More Consecutive Lines |
Many Ex commands can be given a [range] of lines to act upon. We can specify the start and end of a range with either a line number, a mark, or a pattern.
One of the strengths of Ex commands is that they can be executed across a range of lines. We’ll use this short excerpt of HTML as an example:
| 1: | <!DOCTYPE html><!-- --> |
| 2: | <html><!-- --> |
| 3: | <head><title>Practical Vim</title></head><!-- --> |
| 4: | <body><h1>Practical Vim</h1></body><!-- --> |
| 5: | </html><!-- --> |
To demonstrate, we’ll use the :print command, which simply echoes the specified lines below Vim’s command line. This command doesn’t perform any useful work, but it helps to illustrate ...