Using vim to edit crontab on Mac OS/X

Was trying to edit my crontab after making some changes to my .bashrc file and came across this strange error while saving

crontab: temp file must be edited in place

You can solve this in one of two ways
1) Use vi as your editor (EDITOR=vi crontab -e)
2) Set some special flags set in your vimrc to allow crontab editing to work properly

In your bashrc or where ever you store your aliases (I use a separate .aliases/commands config file that I source from .bashrc)

alias crontab=”VIM_CRONTAB=true EDITOR=vim crontab”

and then in your .vimrc


" Lets get crontab editing working
if $VIM_CRONTAB == 'true'
set nobackup
set nowritebackup
endif

view raw

gistfile1.vim

hosted with ❤ by GitHub

One thought on “Using vim to edit crontab on Mac OS/X

Leave a comment