Useful address specifiers
There are a few useful address specifiers that are well worth remembering. These are:
., which represents the current line$, which represents the last line in the file — for example,:$ddeletes the last line in the buffer't, which represents the line that marktis set to/foo/, which represents the next line wherefoomatches (relative to the cursor position) — for example,:/foo/ddeletes the next line where the textfooappears?foo?, which represents the previous line wherefoomatches (relative to the cursor position) — for example,:?foo?ddeletes the previous line where the textfooappears- You can offset an address with a positive or negative number, e.g.
:+1ddeletes the line one below the cursor, and:-1ddeletes the line one before the cursor
You can also chain these specifiers for some interesting results. For example:
:/foo/+2ddeletes the line that is two lines below the next match offoo:0/import/ddeletes the first line in the buffer that contains the wordimport:/foo/?bar?djumps to the next match offoo, then jumps back from there to the previous match ofbar, then deletes that line
Have a play with these in the editor. The :delete command accepts any of these address, so give it a try.