Replace all strings except the parenthesis part in vim

Viewed 86

I have a text as follows.

cat
dog
elephant
cat (1)
zebra(1)
snow leopard
shark (other)
animal (hi) (2)

and I want to replace them as follows.

[[cat]]
[[dog]]
[[elephant]]
[[cat]] (1)
[[zebra]](1)
[[snow leopard]]
[[shark]] (other)
[[animal (hi)]] (2)

Any ideas?

Thank you for advance.

Note the difference between cat (1) and zebra(1)(line 4~5), the space.

2 Answers
Related