I have defined a command for absolute value using providecommand. Initially, I simply used
\providecommand{\abs}[1]{\lvert#1\rvert}
That was working fine until I needed to take the absolute value of an integral, and the lines did not scale at all. To make the lines scale, I tried
\providecommand{\abs}[1]{\left\lvert#1\right\rvert}
This works in the document, but my editor (overleaf) does not like it at all, and has highlighted all subsequent text in red - an error message intermittently displays saying command may only be used in math mode. Is my use OK (and should I therefore ignore the error message - can I override it?) or is there a better way of writing it?
Thanks

This is some text $\abs{25}$ and more text(note the$signs that open and close math mode). – Marijn Aug 10 '20 at 16:05\sum_n), I'd rather recommend using\DeclarePairedDelimiterto define a better abs command (disclaimer I wrote it) – daleif Aug 11 '20 at 05:07\providecommand. If the command is already defined, you'll get either puzzling output or puzzling errors. With\newcommandyou'd instead get a clear error message and can decide whether to use\renewcommandor a different name. – egreg Sep 10 '20 at 10:45