How to remove blank lines using VI


Template level External Article ID

KBA00020717

Issue

Use the syntax below to remove blank lines in a file being edited by VI

Resolution

  • Enter the following when in the VI editor:
    :g/^$/d 
  • To delete all blank lines in a file even with spaces in them, enter the following command.
    :v/./d
  • For more VI commands and information please go here for a comprehensive VI tutorial created by IBM: http://www.ibm.com/developerworks/aix/tutorials/au-unixtips2/