aboutsummaryrefslogtreecommitdiffstats
path: root/vim/vimrcs
diff options
context:
space:
mode:
Diffstat (limited to 'vim/vimrcs')
-rw-r--r--vim/vimrcs/codecmd.vim9
-rw-r--r--vim/vimrcs/keybind.vim4
-rw-r--r--vim/vimrcs/match.vim9
-rw-r--r--vim/vimrcs/plugs.vim3
4 files changed, 11 insertions, 14 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
diff --git a/vim/vimrcs/keybind.vim b/vim/vimrcs/keybind.vim
index 123c82d..5f90e19 100644
--- a/vim/vimrcs/keybind.vim
+++ b/vim/vimrcs/keybind.vim
@@ -3,9 +3,9 @@ map H 0
3map J :<C-u>exe "normal! ".v:count1*10."j"<CR> 3map J :<C-u>exe "normal! ".v:count1*10."j"<CR>
4map K :<C-u>exe "normal! ".v:count1*10."k"<CR> 4map K :<C-u>exe "normal! ".v:count1*10."k"<CR>
5map L $ 5map L $
6nmap <leader>c <c-w><c-o> "关闭除当前窗口的所有页面 6nmap <leader>c <c-w><c-o> "关闭除当前窗口的所有页面
7nmap <c-s> :w !sudo tee %<cr>L<cr> 7nmap <c-s> :w !sudo tee %<cr>L<cr>
8nmap <leader>p <c-x><c-f> "补全路径 8nmap <leader>p <c-x><c-f> "补全路径
9" nmap <C-tab> :tabn<CR> 9" nmap <C-tab> :tabn<CR>
10nmap <tab> :tabp<CR> 10nmap <tab> :tabp<CR>
11" nmap <alt-tab> :tabnew<CR> 11" nmap <alt-tab> :tabnew<CR>
diff --git a/vim/vimrcs/match.vim b/vim/vimrcs/match.vim
index 0b2c19b..897b3c7 100644
--- a/vim/vimrcs/match.vim
+++ b/vim/vimrcs/match.vim
@@ -1,17 +1,14 @@
1" 各类符号自动匹配 1" 各类符号自动匹配
2inoremap { {<CR>}<ESC>O
3" :inoremap { {}<ESC>i
4" :inoremap } <c-r>=ClosePair('}')<CR>
5:inoremap ( ()<ESC>i 2:inoremap ( ()<ESC>i
6:inoremap ) <c-r>=ClosePair(')')<CR> 3:inoremap ) <c-r>=ClosePair(')')<CR>
7:inoremap [ []<ESC>i 4:inoremap [ []<ESC>i
8:inoremap ] <c-r>=ClosePair(']')<CR> 5:inoremap ] <c-r>=ClosePair(']')<CR>
9:inoremap " ""<ESC>i 6:inoremap { {}<ESC>i
10:inoremap ' ''<ESC>i 7:inoremap } <c-r>=ClosePair('}')<CR>
11 8
12function ClosePair(char) 9function ClosePair(char)
13 if getline('.')[col('.') - 1] == a:char 10 if getline('.')[col('.') - 1] == a:char
14 return "<Right>" 11 return "\<Right>"
15 else 12 else
16 return a:char 13 return a:char
17 endif 14 endif
diff --git a/vim/vimrcs/plugs.vim b/vim/vimrcs/plugs.vim
index d71b846..3426b6a 100644
--- a/vim/vimrcs/plugs.vim
+++ b/vim/vimrcs/plugs.vim
@@ -53,7 +53,6 @@ let NERDTreeShowHidden=1 "
53let NERDTreeIgnore = ['\.pyc$', '\.swp', '\.swo', '\.vscode', '__pycache__'] " 过滤: 所有指定文件和文件夹不显示 53let NERDTreeIgnore = ['\.pyc$', '\.swp', '\.swo', '\.vscode', '__pycache__'] " 过滤: 所有指定文件和文件夹不显示
54autocmd BufWinEnter * if getcmdwintype() == '' | silent NERDTreeMirror | endif " 在每个标签页打开相同的文件树 54autocmd BufWinEnter * if getcmdwintype() == '' | silent NERDTreeMirror | endif " 在每个标签页打开相同的文件树
55 55
56
57" nerdtree-git-plugin 56" nerdtree-git-plugin
58let g:NERDTreeGitStatusIndicatorMapCustom = { 57let g:NERDTreeGitStatusIndicatorMapCustom = {
59 \ 'Dirty' :'Dty', 58 \ 'Dirty' :'Dty',
@@ -115,7 +114,7 @@ map <F3> :silent Tlist<CR> " 按下F3就可以呼出了
115map <space>tl :silent Tlist<CR> " 按下<space>tl就可以呼出了 114map <space>tl :silent Tlist<CR> " 按下<space>tl就可以呼出了
116let Tlist_Ctags_Cmd='/usr/local/bin/ctags' " 因为我们放在环境变量里,所以可以直接执行 115let Tlist_Ctags_Cmd='/usr/local/bin/ctags' " 因为我们放在环境变量里,所以可以直接执行
117let Tlist_Use_Right_Window=1 " 让窗口显示在右边,0的话就是显示在左边 116let Tlist_Use_Right_Window=1 " 让窗口显示在右边,0的话就是显示在左边
118let Tlist_Show_One_File=0 " 让taglist可以同时展示多个文件的函数列表 117let Tlist_Show_One_File=1 " 让taglist可以同时展示多个文件的函数列表
119let Tlist_File_Fold_Auto_Close=0 " 非当前文件列表折叠隐藏 118let Tlist_File_Fold_Auto_Close=0 " 非当前文件列表折叠隐藏
120let Tlist_Exit_OnlyWindow=1 " 当taglist是最后一个分割窗口时,自动推出vim 119let Tlist_Exit_OnlyWindow=1 " 当taglist是最后一个分割窗口时,自动推出vim
121let Tlist_Process_File_Always=1 " 是否一直处理tags.1:处理;0:不处理 120let Tlist_Process_File_Always=1 " 是否一直处理tags.1:处理;0:不处理