handle formatting using cursor movement