Reputation: 15
first but not least post here. I’d like some help with repetitive tasks that I’m performing at job right now. There are: How can I substitute in Vim a way to remove unwanted spaces within angle brackets from a mail list? Unfortunately, I couldn’t find out a clever way to deal with, I struggled a lot using \zs
and \ze
features, lookahead lokbehind regex but without a satisfactory solution. There are a sample:
Bilbo Baggins <bilbo. baggins @ middleearth.net>; Galadriel < galadriel @middleearth.net >; Daeron < [email protected] >; Gandalf < gandalf @middleearth.net>; Thorin II Oakenshield < thorin.oakenshield @ middleearth.net >; Aragorn < aragorn @ middleearth.net
And removing unwanted spaces will result in:
Bilbo Baggins <[email protected]>; Galadriel <[email protected]>; Daeron <[email protected]>; Gandalf <[email protected]>; Thorin II Oakenshield <[email protected]>; Aragorn <[email protected]
If anyone can help I would be very grateful.
Upvotes: 1
Views: 321
Reputation: 6421
I don't know if there is a missing >
at the end of your sample or not but the command below should work anyway:
:s/<.\{-\}\(>\|$\)/\=substitute(submatch(0),'\s','','g')/g
Upvotes: 2