Add test for r.
Fix some numarg handling revealed by this test and others.
Add test for tilde, and fix behaviour at end of lines.
Add a test for x, and fix an end-of-line cursor position.