I'm trying to globally enclose in {}
's all instances of +,-,=
that aren't already so enclosed. But I don't want to do this for lines that are latex commands. Since my latex commands are all on separate lines, and all begin with \
, possibly preceded by tab
s or spaces
, my idea is to do the search and replace on any line except ones whose first non-whitespace character is \
Here's a simple example:
\parindent=0 pt
\parskip=12 pt
$=$
${=}$
My search and replace should operate only on the third line. From what I've read in this forum, the following should work at least for lines that begin with \
, but it doesn't work even for this limited class, so I must be doing something wrong.
:g/^([^\\].*[^\{]=[^\}])/s/=/{=}/g
Could somebody please explain what I'm missing? And of course,
As a bonus, if you could explain how I would do the enclosures for +,-, and =
all in the one command, as opposed to three separate commands that would be most helpful.