I have this long regex string
(\.#.+|__init__\.py.*|\.wav|\.mp3|\.mo|\.DS_Store|\.\.svn|\.png|\.PNG|\.jpe?g|\.gif|\.elc|\.rbc|\.pyc|\.swp|\.psd|\.ai|\.pdf|\.mov|\.aep|\.dmg|\.zip|\.gz|\.so|\.shx|\.shp|\.wmf|\.JPG|\.jpg.mno|\.bmp|\.ico|\.exe|\.avi|\.docx?|\.xlsx?|\.pptx?|\.upart)$
and I would like to split it by |
and have each component on a new line.
So something like this in the final form
(\.#.+|
__init__\.py.*|
\.wav|
\.mp3|
\.mo|
\.DS_Store|
... etc
I know I can probably do this as a macro, but I figured someone smarter can find a faster/easier way.
Any tips and helps are appreciated. Thanks!
Give this a try:
:s/|/|\r/g
The above will work on the current line.
To perform the substitution on the entire file, add a %
before the s:
:%s/|/|\r/g
Breakdown:
: - enter command-line mode
% - operate on entire file
s - substitute
/ - separator used for substitute commands (doesn't have to be a /)
| - the pattern you want to replace
/ - another separator (has to be the same as the first one)
|\r - what we want to replace the substitution pattern with
/ - another separator
g - perform the substitution multiple times per line
Replace each instance of |
with itself and a newline (\r
):
:s/|/|\r/g
(ensure your cursor is on the line in question before executing)
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