diff options
Diffstat (limited to 'vim/vimrcs/codecmd.vim')
-rw-r--r-- | vim/vimrcs/codecmd.vim | 9 |
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 | |||
5 | autocmd FileType asm,nasm,vim,sh,makefile set tabstop=4 softtabstop=4 shiftwidth=4 noexpandtab | 5 | autocmd FileType asm,nasm,vim,sh,makefile set tabstop=4 softtabstop=4 shiftwidth=4 noexpandtab |
6 | 6 | ||
7 | set showmatch " 在输入括号时光标会短暂地跳到与之相匹配的括号处 | 7 | set showmatch " 在输入括号时光标会短暂地跳到与之相匹配的括号处 |
8 | set wrap " 设置自动折行 | 8 | set nowrap " 设置自动折行 |
9 | |||
9 | set textwidth=500 " 设置自动换行的长度 | 10 | set textwidth=500 " 设置自动换行的长度 |
10 | set lbr | 11 | set lbr " 设置自动换行 |
11 | set foldmethod=syntax " 设置按语法折叠代码 | 12 | set foldmethod=syntax " 设置按语法折叠代码 |
12 | set nofoldenable " 在打开文件时不要折叠 | 13 | set nofoldenable " 在打开文件时不要折叠 |
13 | 14 | ||
@@ -21,12 +22,12 @@ autocmd FileType php set omnifunc=phpcomplete#CompletePHP | |||
21 | autocmd FileType c set omnifunc=ccomplete#Complete | 22 | autocmd FileType c set omnifunc=ccomplete#Complete |
22 | 23 | ||
23 | " 要求格式化之后的代码不要移动光标,并且不要删除换行符和空行,保留原来的视图 | 24 | " 要求格式化之后的代码不要移动光标,并且不要删除换行符和空行,保留原来的视图 |
24 | autocmd BufReadPost,BufWritePre *.html,*.vim normal! g1G=G`"z<CR> | 25 | autocmd BufReadPost,BufWritePre *.html,*.vim,*.sh,*.py normal! g1G=G`"z<CR> |
25 | " 在保存时自动使用clang-format格式化代码 | 26 | " 在保存时自动使用clang-format格式化代码 |
26 | augroup FormatAutocmd | 27 | augroup 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) |
32 | augroup END | 33 | augroup END |