Vim: Delete all blank lines until first non-blank line

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.

1 Answer

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 .).

2

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

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

You Might Also Like