Typing in
|\sin x|
is a very common error and my eyes bleed every time I see it.
The problem is that | is treated as an ordinary symbol, which makes it handy to type |x|, but fails miserably when one has
|-x|
(try it) because the rule is that a binary operation symbol surrounded by ordinary ones will get \medmuskip space around it. Similarly, if a math operator follows an ordinary symbol, a thin space will be inserted, which is good for
2\sin x
where we don't want the “2” to be attached to the “s”. But the rule applies to |\sin x| as well. No space is inserted between x and |, because they're two ordinary symbols.
A way out would be to type
|{\sin x}|
or, better,
\mathopen|\sin x|
because no space is inserted between an Open atom and an Op atom.
In view of this deficiency, amsmath defines two new kinds of delimiters, namely \lvert and \rvert, in a way that's equivalent to doing \mathopen| and \mathclose| respectively (but not really so, in order to allow having \bigl\lvert, for instance.
Actually, doing \bigl\lvert is the same as \bigl|, because \bigl will give its following symbol the role of an Open atom. Similarly for \bigr\rvert and \bigr|.
So, no, there's not much you can do once your typescript has |\sin x|. You cannot redefine | to become an Open atom, because this would disrupt the instances in which it is used where a Close atom would be (the second one in |\sin x|).
I've trained myself to type in \lvert...\rvert every time.
You might also use mathtools and do
\DeclareMathDelimiter{\abs}{|}{|}
so
\abs{\sin x}
would do the right thing.
|and\lvertare not the same thing. So it is better to never use|at all. And perhaps define a\absmacro to use\lvert... \rvert. Mathtools has a nice construction to define\abs– daleif Jun 07 '22 at 08:20|left in the manuscript when I'm done. It can mean too many things so it is better to use separate macros – daleif Jun 07 '22 at 08:22\lvertand\rvert. – egreg Jun 07 '22 at 08:24