I can find empty lines doing this command :g/^$. How to extend this command to print 1 line (2 lines, etc.) before exact empty line and after?
:g/^$/.,+2p
will print every empty line and the two lines below. Use :#
instead of :p
if you also want the line numbers.
Note that this won't work if the matched line is the last.
See :help :p
, :help :#
, and :help :range
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With