-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvimrc
More file actions
30 lines (23 loc) · 1.29 KB
/
vimrc
File metadata and controls
30 lines (23 loc) · 1.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
set cindent " 使用 C 风格的自动缩进
set expandtab " 自动扩展 Tab
set tabstop=4 " 设置 Tab 所占的宽度
set softtabstop=4 " 调整 缩进的 表现, 开启 expandtab 的时候, 此选项没用
set shiftwidth=4 " 自动缩进使用的空格数量
set hlsearch " 查找时高亮
set incsearch " 查找时, 每输入一个字符, 自动跳转到第一个匹配的位置
set ignorecase " 查找时忽略大小写
set smartcase " 查找时, 如果首字母大写, 依然区分大小写
set number " 默认显示行号
autocmd FileType make set noexpandtab " Makefile 不扩展 Tab
"对行末的空格标红
highlight WhitespaceEOL ctermbg=red guibg=red
match WhitespaceEOL /\s\+$/
autocmd BufWritePre * :%s/\s\+$//e " 自动去除行尾的空格
" 保存时, 使用 clang-format 格式化代码
" dpkg -L clang-format | grep clang-format.py
function! Formatonsave()
let l:lines = "all"
py3f /usr/share/vim/addons/syntax/clang-format.py
endfunction
autocmd BufWritePre *.h,*.cc,*.cpp,*.c call Formatonsave()
set fileencodings=ucs-bom,utf-8,gbk,big5,gb18030,latin1