I'm able to find empty lines with /^$, but when I go to remove them using :%s/^$//, nothing seems to happen. Yet, some form of substitution is being made, because the status line reads XX substitutions on XX lines where XX is the number of empty lines in the file.


  1. What substitutions are being made, as indicated by the status line?
  2. How do I accomplish what I want to do (eliminate empty lines from a file)?
  • One answer to #2 is :g/^$/d
    – chb
    Commented Jun 1, 2019 at 1:46
  • A solution would be to replace an actual character: :%s/^\n// but that depends on file format.
    – aragaer
    Commented Jun 1, 2019 at 10:26

1 Answer 1

  1. ^ and $ are zero-width items, so when you do :%s/^$// you’re substituting zero characters for zero characters
  2. To actually perform the substitution, the idioms are



Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.