how to delete all lines in a file using VI

 

  • Make sure you are in the command mode in Vim by pressing the Esc key.
  • You need to be at the beginning of the file. Press gg for that. This means pressing the g key in quick succession.
  • Now press dG. This means pressing the key d and then hold Shift and press g. Yes, G is uppercase and you'll have to use shift key here the same way you type G.

In short: Esc+gg+dG is what you need to do for deleting all the lines of the file in Vim.

No comments:

Post a Comment

How to increase ESXi webclient login user application timeout

 To increase the default 15min timeout to 2hr Login to the esxi webclient on the right top corner ->Click the User login tab Select "...