DEV Community

Count how many paragraphs in vim

Sérgio Araújo on June 01, 2019

The best way to count paragraphs in my opinion is counting all blank lines that appears after each paragraph. so, let's remove consecuteve blank li...
Collapse
 
coreyja profile image
Corey Alexander

This is fun! I love finding new fun things to do in VIM! Thanks for the post!

Think you could help break down that first global command regular expression for me? I'm not the best at regular expressions yet and would love to understand how that first one works a bit better!

Collapse
 
Sloan, the sloth mascot
Comment deleted
Collapse
 
coreyja profile image
Corey Alexander

Ohh Awesome! That makes sense! The \_$ and \_^ are new to me, that's really cool!

I'll definitely remember those! Thanks again man!

Collapse
 
voyeg3r profile image
Sérgio Araújo

The full explanation from stackoverflow:
_$ means the end-of-line that can be used inside a pattern ($ can only be used at the end of the pattern.) Same is with _^ that means the start of a line and can be used anywhere inside the pattern. So, the pattern matches an empty line, a newline, and again an empty line. See: vimdoc.sourceforge.net/htmldoc/pat...