You should use \_.\{-}
instead of .*
.
\_.
matches any character including end-of-line. However, as :h \_.
warns, using it with *
will match all text to the end of the buffer.
\{-}
is similar to *
, matching 0 or more instances of the proceeding atom. But it matches as few as possible instead of as many as possible. This makes \{-}
safe if your example pattern appears more than once. For example:
author = {{foo
bar}},
editor = {{buz
baz}},
Using %s/{{\(\_.*\)}}/{\1}/g
changes the starting double brace for author, but the closing double brace for editor. Since *
matches as many atoms as possible, the pattern matches until the last double brace it finds. This results in the following:
author = {foo
bar}},
editor = {{buz
baz},
However, using %s/{{\(\_.\{-}\)}}/{\1}/g
gives the desired result for both author and editor as it stops searching at the first double brace it finds:
author = {foo
bar},
editor = {buz
baz},
ds{