In the Vim editor, we can delete lines with the
Follow these steps to delete a single line:
Press ESC to go to Normal mode.
Place the cursor on the line you need to delete.
dd. This will delete the current line.
If you press
ddmultiple times, it will delete multiple lines.
Follow these steps to delete a specific line:
Press Esc then
: to go to command mode.
nd and hit Enter where
nd is the line number. For example, if you want to delete the fifth line, then you should use
To delete line numbers 5 to 10, use:
We can also use certain characters to specify a range, such as:
.(dot) specifies the current line.
＄specifies the last line.
%specifies all lines.
To delete all lines below the current line, use the following command.
. in the above code denotes the current line, and the
＄ denotes the last line. This command will delete all the lines below the current line.
To delete all the lines above the current line, use the following command.
To delete all the lines of the file, use the following command.
View all Courses