用一下命令编辑vimrc文件: sudo vim /etc/vim/vimrc 在vimrc文件最后添加一下几行: set ts = 4 set expandtab set autoindent 保存,退出,搞定。