I noticed that the following mapping does not cause an infinite recursion (when pressing
:map x x
I didn't see anything in Vim's documentation that would explain this.
Further experimentation seems to suggest that when the right-hand-side of a mapping starts with the left-hand-side, there is no infinite recursion. For example,
:map x Xx causes infinite recursion, but
:map x xX doesn't (when pressing
My expectation is that when the contents of the left-hand-side are included on the right-hand-side, this would result in an infinite recursion, regardless of the positioning within the right-hand-side.
Is there some documented reason for the behavior I'm observing (e.g., special handling if the beginning of the right-hand-side matches the left-hand-side)?