I want to shift a line by some amount in some direction. Here the direction is fixed, orthogonal to the line. One difficulty is that the line should be drawn like it would be at the origin position. The solution I have almost does what I want, except that the shifted line is longer, because it is not constrained by the nodes.
The examples I found e.g. Shifting a line joining nodes in TikZ affect how the line is drawn.
Something like (A) edge[shift left=2cm] (B);
would be nice.
\documentclass[tikz, border=2mm]{standalone}
\usepackage{tikz}
\usetikzlibrary{positioning,calc}
\begin{document}
\begin{tikzpicture}
\node (A) at (3,0) {$A$};
\node (B) at (5,1) {$B$};
\path[-]
(A) edge (B)
($(A)!5mm!90:(B)$) edge node{shifted} ($(B)!5mm!-90:(A)$);
\end{tikzpicture}
\end{document}