因为不喜欢nano,想换用vim,google 中有用环境变量的,有用 select-editor 的,但select-editor不是总是存在的,只好自己分析研究下了。
在debian (wheezy/sid) ubuntu 下分别用 strace 对crontab -e 进行了跟踪, 发现crontab都是使用sensible-editor作为编辑器的。ubuntu下sensible-editor 会查找 /home/<username>/.selected_editor 文件,如果没找到,则列出系统当前可用的编辑器,提示用户选择,如果文件存在,读取文件内容并用指定的编辑器打开文件;debian下 sensible-editor查找系统变量中各bin目录下是否存在editor,然后使用editor打开文件,同时editor是指向 /etc/alternatives/editor 的软链接,/etc/alternatives/editor 又是指向具体编辑器的软链接,所以修改方法自然明了了,alternatives是debian 包管理系统提供,所以使用以下命令可以直接修改alternatives 下的软链接:
update-alternatives --config editor
然后选择自己喜欢的编辑器就ok了。