I want to do a search and replace in a latex file as follows:
:%s/\\todo{.*}/\1/gc
That should transform texts like "abc \todo{def} ghi
" into "abc def ghi
". It happens that when the \todo{...}
command is inside another one, vim tries to match the second (closing) bracket with that of the outer command. For instance, "abc \textbf{def \todo{ghi} jkl}
" becomes "abc \textbf{def ghi} jkl
" when it should be "abc \textbf{def ghi jkl}
".
Is there a way to match the corresponding bracket?
Edit:
Sorry for not pointing that out before. It would be nice if it could match exactly the correspondent bracket since there can be commands inside as well as ouside the \todo{...}
command.
Edit:
"abc \todo{def \textbf{ghi} jkl}" -> "abc def \textbf{ghi} jkl"
"abc \textbf{def \todo{ghi} jkl}" -> "abc \textbf{def ghi jkl}"