Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Vim: delete empty lines within a visual selected area

Tags:

vim

In ex-mode I can use :g/^$/d for the whole file. How to do it for a visual selected part of the file?

like image 475
vbd Avatar asked Nov 27 '09 09:11

vbd


1 Answers

Select text visually, press : to enter command mode, and use the same command or use the '< and '> markers. E.g. :'<,'><your command here>.

For your particular use case, the final command would be:

:'<,'>g/^$/d
like image 95
Alex Budovski Avatar answered Nov 05 '22 17:11

Alex Budovski