NOTE : the answer, which says that the ZZ command is used, does not work for me on my Mavericks system, but it is probably related to something in my vim configuration, because if I start with an untouched .vimrc , the accepted answer works . My answer may work for you if there is no other solution.
On MacOS X, according to the crontab man page, the temporary crontab file created with crontab -e must be edited in-place. Vim does not edit by default by default (but crontab -e may require a special case to support it), so if your environment variable $EDITOR set to vi (default) or vim , editing crontab will always fail.
To get Vim to edit the file in place, you need to do:
:setlocal nowritebackup
This will allow you to update crontab when you run crontab -e with the commands :wq or ZZ .
You can add an auto command to your .vimrc so that it works automatically when editing crontabs:
autocmd FileType crontab setlocal nowritebackup
Another way is to add setlocal nowritebackup to ~/.vim/after/ftplugin/crontab.vim , which will be automatically loaded by Vim when you edit the crontab file if you have the Filetype plugin enabled. You can also check the OS if you use your vim files on multiple platforms:
""In ~/.vim/after/ftplugin/crontab.vim if has("mac") setlocal nowritebackup endif
Dave Meybohm Jan 17 '14 at 19:22 2014-01-17 19:22
source share