Reputation: 404
I have a csv files in VIM that looks like this:
aaa,bbb,ccc (Friday, 23/06/17)
ddd,eee,fff (Saturday, 24/06/17)
ggg,hhh,iii (Sunday, 25/06/17)
I would like to delete all parenthesis & its content to look like this:
aaa,bbb,ccc
ddd,eee,fff
ggg,hhh,iii
I have tried doing this but it's only deleting the parenthesis
:%s/(*)//g
Upvotes: 2
Views: 631
Reputation: 755
You almost had it, you're missing the .
:
:%s/(.*)//g
The dot matches all the characters, so using .*
means find all strings of characters of any length
Edit:
As sundeep stated, g
if for matching all occurrences in the same line and .*
will greedily match from the first (
to the last )
in the line, so there won't be another to match in the same line, so it can be removed. You can match only simple pairs of braces with ([^(]*)
which means find any string of characters that don't include (
that is surrounded by ()
. So the modified suggestion is to use:
:%s/([^(]*)//g
Upvotes: 7
Reputation: 10371
:%s/(.*)//g
or da(
from inside the ()
for each line if you intend to delete few leaving others.
Upvotes: 2