copied from vim repository