aboutsummaryrefslogtreecommitdiffstats
path: root/vim/vimrcs/codecmd.vim
diff options
context:
space:
mode:
Diffstat (limited to 'vim/vimrcs/codecmd.vim')
-rw-r--r--vim/vimrcs/codecmd.vim9
1 files changed, 5 insertions, 4 deletions
diff --git a/vim/vimrcs/codecmd.vim b/vim/vimrcs/codecmd.vim
index cbe08bf..278e4f0 100644
--- a/vim/vimrcs/codecmd.vim
+++ b/vim/vimrcs/codecmd.vim
@@ -5,9 +5,10 @@ set softtabstop=4
5autocmd FileType asm,nasm,vim,sh,makefile set tabstop=4 softtabstop=4 shiftwidth=4 noexpandtab 5autocmd FileType asm,nasm,vim,sh,makefile set tabstop=4 softtabstop=4 shiftwidth=4 noexpandtab
6 6
7set showmatch " 在输入括号时光标会短暂地跳到与之相匹配的括号处 7set showmatch " 在输入括号时光标会短暂地跳到与之相匹配的括号处
8set wrap " 设置自动折行 8set nowrap " 设置自动折行
9
9set textwidth=500 " 设置自动换行的长度 10set textwidth=500 " 设置自动换行的长度
10set lbr 11set lbr " 设置自动换行
11set foldmethod=syntax " 设置按语法折叠代码 12set foldmethod=syntax " 设置按语法折叠代码
12set nofoldenable " 在打开文件时不要折叠 13set nofoldenable " 在打开文件时不要折叠
13 14
@@ -21,12 +22,12 @@ autocmd FileType php set omnifunc=phpcomplete#CompletePHP
21autocmd FileType c set omnifunc=ccomplete#Complete 22autocmd FileType c set omnifunc=ccomplete#Complete
22 23
23" 要求格式化之后的代码不要移动光标,并且不要删除换行符和空行,保留原来的视图 24" 要求格式化之后的代码不要移动光标,并且不要删除换行符和空行,保留原来的视图
24autocmd BufReadPost,BufWritePre *.html,*.vim normal! g1G=G`"z<CR> 25autocmd BufReadPost,BufWritePre *.html,*.vim,*.sh,*.py normal! g1G=G`"z<CR>
25" 在保存时自动使用clang-format格式化代码 26" 在保存时自动使用clang-format格式化代码
26augroup FormatAutocmd 27augroup FormatAutocmd
27 autocmd! 28 autocmd!
28 autocmd BufWritePre *.c,*.cpp,*.h :normal! ggVG
29 autocmd BufWritePre *.c,*.cpp,*.h :let save_cursor = getpos(".") 29 autocmd BufWritePre *.c,*.cpp,*.h :let save_cursor = getpos(".")
30 autocmd BufWritePre *.c,*.cpp,*.h :normal! ggVG
30 autocmd BufWritePre *.c,*.cpp,*.h :ClangFormat 31 autocmd BufWritePre *.c,*.cpp,*.h :ClangFormat
31 autocmd BufWritePost *.c,*.cpp,*.h :call setpos('.', save_cursor) 32 autocmd BufWritePost *.c,*.cpp,*.h :call setpos('.', save_cursor)
32augroup END 33augroup END