I have some text like this:

Line 1 of text

Line 2 of text.

I want to delete all the blank lines between the two lines of text.

I could put my cursor under the first line and type 5dd, but I'm wondering if it can be done without specifying a number of lines.


Starting from the first blank line from Normal mode, press d/.. Press Enter.

d will delete until / finds the first non-blank character (anything matching .).

  • And if you want to include lines with white-space: d/^\s*$
    – Heptite
    Aug 9 '18 at 22:15
  • I would out of habit have used g/^$/d but this just feels better. Aug 10 '18 at 5:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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