it sounds like you aren't root.
do the following...(omit the prompt obviously)
Password: (enter your root password here)
You obviously need to be in the directory where nagios.cfg is prior to calling vi.
As far as saving from the command line.... Do you mean in vi? If so, after you make your edits to an existing file you:
Hope that helps.