通過編輯vim的配置文件設置以下幾個參數就可以永久更改vim自動縮進字符數。
set tabstop=4 #設置tab鍵佔用4個空格的長度。
set shiftwidth=4 #設置手動縮進時佔用4個空格長度。
set softtabstop=4 #設置tab鍵實際佔用4個空格長度。
set expandtab #設置將tab鍵轉換爲softtabstop值的空格數。
Linux kernel的默認值:
set tabstop=8
set softtabstop=8
set shiftwidth=8
set noexpandtab
CentOS下vim配置文件目錄:/etc/vimrc
配置方法:
[root@centos ~]# echo -e "\nset tabstop=4\nset shiftwidth=4\nset softtabstop=4\nset expandtab" >> /etc/vimrc