Monday 13 October 2014

How can I delete all lines in Vim?

To delete all lines in a file with vim you can type:
 :1,$d  
in command mode. Semicolon(:) indicates a command, 1,$ indicates a range that following command will work. In that case from 1st line to the last line. d means delete the specified lines.

Another command for the same purpose is:
 gg  
 dG  
gg takes you to first line and d means delete again and G means to the last line.

And one more command is:
 :%d  

No comments:

Post a Comment