  In an earlier paper we introduced rectangular diagrams of surfaces and showed
that any isotopy class of a surface in the three-sphere can be presented by a
rectangular diagram. Here we study transformations of those diagrams and
introduce moves that allow transition between diagrams representing isotopic
surfaces. We also introduce more general combinatorial objects called mirror
diagrams and various moves for them that can be used to transform presentations
of isotopic surfaces to each other. The moves can be divided into two types so
that, vaguely speaking, type~I moves commute with type~II ones. This
commutation is the matter of the main technical result of the paper. We use it
as well as a relation of the moves to Giroux's convex surfaces to propose a new
method for distinguishing Legendrian knots. We apply this method to show that
two Legendrian knots having topological type $6_2$ are not equivalent. More
applications of the method will be a subject of subsequent papers.
