Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Created an account to post this:

  :v/./,/./-j
in vim will go through the whole file, joining multiple consecutive empty lines into one. Not only it is fork-bomb-level cryptic, but also showcases how you can use addresses to do advanced stuff.

Somewhat more readable version:

  :vglobal /./ .,/./- join
which is: go to every line that doesn't match (vglobal) /./ (is empty) and join lines from that line (.) to the line before (-) the next line that is not empty (/./ again).


Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: