- 1. 创建 .vimrc
- 2. 添加配置
- 3. 创建C文件
找到家目录(aiot@ubuntu:~)创建 .vimrc
# 用touch 创建 .vimrc touch .vimrc # 用ls -al c查看文件是否创建成功 ls -al # 用chmod 给.vimrc 添加权限 sudo chmod 777 .vimrc2. 添加配置
用vim 打开 .vimrc
添加如下配置:
set autoindent set cindent set tabstop=4 set softtabstop=4 set shiftwidth=4 set smarttab set number3. 创建C文件
刚学习C语言的同学不建议!!!
不想写C语言头文件可以如下配置中:
syntax on set tabstop=4 set softtabstop=4 set shiftwidth=4 set nu autocmd BufNewFile *.c exec ":call StrictWarn()" func StrictWarn() call setline(1,"#include") call append(1,"int main(){") call append(2," return 0;") call append(3,"}") endfunc



