Made some code simplification for vi modes.