reorganize for use as vim plugin