I'm trying to match a pattern only when it occurs between matching delimitersFor 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 alternativeg/(\{-}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
Match a pattern within matching delimiters
delimiter matching
You could try something like that::%s/(\s*\(a\)\s*)/\U\1/g(\s*\(a\)\s*) can be decomposed:The first pair of () are the litteral characters\s* match any number of whitespace between the brackets and your patternThe pair of \( and \) captures a subgroupa is the subgroup captured (but you could change it to any pattern)\U\1 is:\U convert to upper case.\1 the first subgroup you capted (with \( and \)).