I'm trying to match a pattern only when it occurs between matching delimiters
For example, in the lines below, I'd like to match the a in the first line, but not the a in the second, which is not inside matching parens
( a )
( b ) a ( b )
The command
:g/(.*a.*)/s/a/A/
obviously doesn't work because it's too greedy.
I would have thought the non-greedy alternative
g/(\{-}a\{-})/s/a/A/
would work, but for some reason it returns
( A )
( b ) A ( b )
Obviously, I don't really understand how the non-greedy syntax works. Any suggestions would be most appreciated! Thanks