PS: When editing password or group files you should use vipw and vigr and FWIW to edit the sudoers file it's common to use visudo. The EDITOR variable allows to replace vi by an editor of your choice.