aboutsummaryrefslogtreecommitdiffstats
path: root/vim
diff options
context:
space:
mode:
authorWe-unite <3205135446@qq.com>2024-06-29 14:20:02 +0800
committerWe-unite <3205135446@qq.com>2024-06-29 14:26:46 +0800
commitc4e535792c80118074b502e583690e9df0aa23c0 (patch)
tree5ace915de19fc8958de029ff7b5c7690cebfe26b /vim
parentafa8fcdfd84544356a052ea0673b04fd5018bd41 (diff)
downloadPardon-main.tar.gz
Pardon-main.zip
updatemain
Diffstat (limited to 'vim')
-rw-r--r--vim/vimrc.tiny13
-rw-r--r--vim/vimrc_origin55
-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
-rw-r--r--vim/vimscript.vim295
7 files changed, 11 insertions, 377 deletions
diff --git a/vim/vimrc.tiny b/vim/vimrc.tiny
deleted file mode 100644
index 890037a..0000000
--- a/vim/vimrc.tiny
+++ /dev/null
@@ -1,13 +0,0 @@
1" Vim configuration file, in effect when invoked as "vi". The aim of this
2" configuration file is to provide a Vim environment as compatible with the
3" original vi as possible. Note that ~/.vimrc configuration files as other
4" configuration files in the runtimepath are still sourced.
5" When Vim is invoked differently ("vim", "view", "evim", ...) this file is
6" _not_ sourced; /etc/vim/vimrc and/or /etc/vim/gvimrc are.
7
8" Debian system-wide default configuration Vim
9set runtimepath=~/.vim,/var/lib/vim/addons,/usr/share/vim/vimfiles,/usr/share/vim/vim82,/usr/share/vim/vimfiles/after,/var/lib/vim/addons/after,~/.vim/after
10
11set compatible
12
13" vim: set ft=vim:
diff --git a/vim/vimrc_origin b/vim/vimrc_origin
deleted file mode 100644
index 1fcd4d7..0000000
--- a/vim/vimrc_origin
+++ /dev/null
@@ -1,55 +0,0 @@
1" All system-wide defaults are set in $VIMRUNTIME/debian.vim and sourced by
2" the call to :runtime you can find below. If you wish to change any of those
3" settings, you should do it in this file (/etc/vim/vimrc), since debian.vim
4" will be overwritten everytime an upgrade of the vim packages is performed.
5" It is recommended to make changes after sourcing debian.vim since it alters
6" the value of the 'compatible' option.
7
8runtime! debian.vim
9
10" Vim will load $VIMRUNTIME/defaults.vim if the user does not have a vimrc.
11" This happens after /etc/vim/vimrc(.local) are loaded, so it will override
12" any settings in these files.
13" If you don't want that to happen, uncomment the below line to prevent
14" defaults.vim from being loaded.
15" let g:skip_defaults_vim = 1
16
17" Uncomment the next line to make Vim more Vi-compatible
18" NOTE: debian.vim sets 'nocompatible'. Setting 'compatible' changes numerous
19" options, so any other options should be set AFTER setting 'compatible'.
20"set compatible
21
22" Vim5 and later versions support syntax highlighting. Uncommenting the next
23" line enables syntax highlighting by default.
24if has("syntax")
25 syntax on
26endif
27
28" If using a dark background within the editing area and syntax highlighting
29" turn on this option as well
30"set background=dark
31
32" Uncomment the following to have Vim jump to the last position when
33" reopening a file
34"au BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g'\"" | endif
35
36" Uncomment the following to have Vim load indentation rules and plugins
37" according to the detected filetype.
38"filetype plugin indent on
39
40" The following are commented out as they cause vim to behave a lot
41" differently from regular Vi. They are highly recommended though.
42"set showcmd " Show (partial) command in status line.
43"set showmatch " Show matching brackets.
44"set ignorecase " Do case insensitive matching
45"set smartcase " Do smart case matching
46"set incsearch " Incremental search
47"set autowrite " Automatically save before commands like :next and :make
48"set hidden " Hide buffers when they are abandoned
49"set mouse=a " Enable mouse usage (all modes)
50
51" Source a global configuration file if available
52if filereadable("/etc/vim/vimrc.local")
53 source /etc/vim/vimrc.local
54endif
55
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:不处理
diff --git a/vim/vimscript.vim b/vim/vimscript.vim
deleted file mode 100644
index 001b060..0000000
--- a/vim/vimscript.vim
+++ /dev/null
@@ -1,295 +0,0 @@
1" 主要参考 http://www.cnblogs.com/ma6174/archive/2011/12/10/2283393.html
2" 额外添加了 ctags, YouCompleteMe等
3" 主要特点
4
5"1.按F5可以直接编译并执行C、C++、java代码以及执行shell脚本,按“F8”可进行C、C++代码的调试
6"2.自动插入文件头 ,新建C、C++源文件时自动插入表头:包括文件名、作者、联系方式、建立时间等,读者可根据需求自行更改
7"3.映射“Ctrl + A”为全选并复制快捷键,方便复制代码
8"4.按“F2”可以直接消除代码中的空行
9"5.“F3”可列出当前目录文件,打开树状文件目录
10"6. 支持鼠标选择、方向键移动
11"7. 代码高亮,自动缩进,显示行号,显示状态行
12"8. 按“Ctrl + P”可自动补全
13"9. []、{}、()、""、‘ ‘等都自动补全 --- 如果需要{}做函数形式的补全(右括号自动换行,加一个空行,光标定位到空行,可以看下面的修改提示)
14"10. 使用YouCompleteMe提供C++的自动补全提示,效果类似 Visual Studio那种,可以解析系统头文件
15
16
17""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
18" """""""""""""" Suzzz """""""""""""""""""""
19"https://github.com/gmarik/Vundle.vim#about
20
21set nocompatible " be iMproved, required
22filetype off " required
23
24set rtp+=~/.vim/bundle/Vundle.vim
25
26call vundle#begin()
27" let Vundle manage Vundle, required
28Plugin "gmarik/Vundle.vim"
29" plugin on GitHub repo 添加github上的vimn插件,形式非常简单
30Plugin "tpope/vim-fugitive"
31"语法检查
32Plugin "scrooloose/syntastic"
33"让 syntastic忽略 python 文件
34let g:syntastic_ignore_files=[".*\.py$"]
35"补全 python
36Plugin "davidhalter/jedi"
37Plugin "rstacruz/sparkup", {"rtp": "vim/"}
38" YouCompleteMe插件,很好的智能提示,基本达到 IDE 级别
39Plugin "Valloric/YouCompleteMe"
40
41call vundle#end() " required
42
43filetype plugin indent on " required
44" To ignore plugin indent changes, instead use:
45"filetype plugin on
46" YouCompleteMe 通过这个cm_global_ycm_extra_conf来获得补全规则,可以如下指定,也可以每次放置在工作目录
47let g:ycm_global_ycm_extra_conf=‘~/.vim/bundle/YouCompleteMe/third_party/ycmd/cpp/ycm/.ycm_extra_conf.py‘
48"让YouCompleteMe同时利用原来的ctags
49let g:ycm_collect_identifiers_from_tag_files = 1
50
51" """"""""""""" By ma6174 """""""""""""""""""""
52" 显示相关
53""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
54autocmd InsertLeave * se nocul " 用浅色高亮当前行
55autocmd InsertEnter * se cul " 用浅色高亮当前行
56"set ruler " 显示标尺
57set showcmd " 输入的命令显示出来,看的清楚些
58"set whichwrap+=<,>,h,l " 允许backspace和光标键跨越行边界(不建议)
59"set scrolloff=3 " 光标移动到buffer的顶部和底部时保持3行距离
60set novisualbell " 不要闪烁(不明白)
61"set statusline=%F%m%r%h%w\ [FORMAT=%{&ff}]\ [TYPE=%Y]\ [POS=%l,%v][%p%%]\ %{strftime(\"%d/%m/%y\ -\ %H:%M\")} "状态行显示的内容
62set laststatus=2 " 启动显示状态行(1),总是显示状态行(2)
63"set foldenable " 允许折叠
64"set foldmethod=manual " 手动折叠
65"set background=dark "背景使用黑色
66" 显示中文帮助
67if version >= 603
68 set helplang=cn
69 set encoding=utf-8
70endif
71
72set fencs=utf-8,ucs-bom,shift-jis,gb18030,gbk,gb2312,cp936
73set termencoding=utf-8
74set encoding=utf-8
75set fileencodings=ucs-bom,utf-8,cp936
76set fileencoding=utf-8
77
78"键盘命令
79
80""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
81
82"map <C-A> ggVGY
83"map! <C-A> <Esc>ggVGY
84"map <F12> gg=G
85""去空行
86"nnoremap <F2> :g/^\s*$/d<CR>
87
88"比较文件
89nnoremap <C-F2> :vert diffsplit
90
91"列出当前目录文件
92map <F3> :tabnew .<CR>
93
94"打开树状文件目录
95map <C-F3> \be
96
97"C,C++ 按F5编译运行
98map <F5> :call CompileRunGcc()<CR>
99
100func! CompileRunGcc()
101
102 exec "w"
103 if &filetype == ‘c‘
104 exec "!g++ % -o %<"
105 exec "! ./%<"
106 elseif &filetype == ‘cpp‘
107 exec "!g++ % -o %<"
108 exec "! ./%<"
109 elseif &filetype == ‘java‘
110 exec "!javac %"
111 exec "!java %<"
112 elseif &filetype == ‘sh‘
113 :!./%
114 endif
115endfunc
116
117"C,C++的调试
118
119map <F8> :call Rungdb()<CR>
120
121func! Rungdb()
122 exec "w"
123 exec "!g++ % -g -o %<"
124 exec "!gdb ./%<"
125endfunc
126
127""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
128
129""实用设置
130
131"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
132
133" 设置当文件被改动时自动载入
134set autoread
135
136" quickfix模式
137autocmd FileType c,cpp map <buffer> <leader><space> :w<cr>:make<cr>
138
139"代码补全
140set completeopt=preview,menu
141
142"允许插件
143filetype plugin on
144
145"共享剪贴板
146set clipboard+=unnamed
147
148"从不备份
149"set nobackup
150
151"make 运行
152:set makeprg=g++\ -Wall\ \ %
153
154"自动保存
155set autowrite
156
157set ruler " 打开状态栏标尺
158set cursorline " 突出显示当前行
159set magic " 设置魔术
160set guioptions-=T " 隐藏工具栏
161set guioptions-=m " 隐藏菜单栏
162" 设置在状态行显示的信息
163"set statusline=\ %<%F[%1*%M%*%n%R%H]%=\ %y\ %0(%{&fileformat}\ %{&encoding}\ %c:%l/%L%)\
164
165"set foldcolumn=0
166"set foldmethod=indent
167"set foldlevel=3
168"set foldenable " 开始折叠
169
170" 去掉输入错误的提示声音
171set noeb
172
173" 在处理未保存或只读文件的时候,弹出确认
174set confirm
175
176" 自动缩进
177"set autoindent
178"set cindent
179
180" 在行和段开始处使用制表符
181set smarttab
182
183" 历史记录数
184set history=1000
185
186"禁止生成临时文件
187set noswapfile
188
189"搜索忽略大小写
190set ignorecase
191
192"搜索逐字符高亮
193set hlsearch
194set incsearch
195
196"行内替换
197set gdefault
198
199"语言设置
200set langmenu=zh_CN.UTF-8
201set helplang=cn
202
203" 我的状态行显示的内容(包括文件类型和解码)
204"set statusline=%F%m%r%h%w\ [FORMAT=%{&ff}]\ [TYPE=%Y]\ [POS=%l,%v][%p%%]\ %{strftime(\"%d/%m/%y\ -\ %H:%M\")}
205"set statusline=[%F]%y%r%m%*%=[Line:%l/%L,Column:%c][%p%%]
206
207" 总是显示状态行
208set laststatus=2
209
210" 命令行(在状态行下)的高度,默认为1,这里是2
211set cmdheight=2
212
213" 带有如下符号的单词不要被换行分割
214set iskeyword+=_,$,@,%,#,-
215
216set selection=exclusive
217set selectmode=mouse,key
218
219" 通过使用: commands命令,告诉我们文件的哪一行被改变过
220set report=0
221
222" 光标移动到buffer的顶部和底部时保持3行距离
223set scrolloff=3
224
225" 为C程序提供自动缩进
226
227" 高亮显示普通txt文件(需要txt.vim脚本)
228
229au BufRead,BufNewFile * setfiletype txt
230
231"自动补全
232"by Suzzz: 原作者这种设置,输入{会自动补全,并且中间插入一个空行,将光标定位到空行。这对于函数是OK的,但是使用花括号初始化数组、vector时就不方便了。所以改为现在这种。只是补全,然后光标在左右括号中间。
233":inoremap { {<CR>}<ESC>O
234:inoremap ( ()<ESC>i
235:inoremap ) <c-r>=ClosePair(‘)‘)<CR>
236:inoremap { {}<ESC>i
237:inoremap } <c-r>=ClosePair(‘}‘)<CR>
238:inoremap [ []<ESC>i
239:inoremap ] <c-r>=ClosePair(‘]‘)<CR>
240:inoremap " ""<ESC>i
241:inoremap ‘ ‘‘<ESC>i
242
243function! ClosePair(char)
244 if getline(‘.‘)[col(‘.‘) - 1] == a:char
245 return "\<Right>"
246 else
247 return a:char
248 endif
249endfunction
250
251set completeopt=longest,menu
252
253"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
254
255" CTags的设定
256
257"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
258
259let Tlist_Sort_Type = "name" " 按照名称排序
260let Tlist_Use_Right_Window = 1 " 在右侧显示窗口
261let Tlist_Compart_Format = 1 " 压缩方式
262let Tlist_Exist_OnlyWindow = 1 " 如果只有一个buffer,kill窗口也kill掉buffer
263let Tlist_File_Fold_Auto_Close = 0 " 不要关闭其他文件的tags
264let Tlist_Enable_Fold_Column = 0 " 不要显示折叠树
265autocmd FileType java set tags+=D:\tools\java\tags
266"autocmd FileType h,cpp,cc,c set tags+=D:\tools\cpp\tags
267"let Tlist_Show_One_File=1 "不同时显示多个文件的tag,只显示当前文件的
268"设置tags
269set tags=tags
270"set autochdir
271
272""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
273
274"其他东东
275
276"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
277
278"默认打开Taglist
279let Tlist_Auto_Open=1
280
281""""""""""""""""""""""""""""""
282
283" Tag list (ctags)
284
285""""""""""""""""""""""""""""""""
286
287let Tlist_Ctags_Cmd = ‘/usr/bin/ctags‘
288let Tlist_Show_One_File = 1 "不同时显示多个文件的tag,只显示当前文件的
289let Tlist_Exit_OnlyWindow = 1 "如果taglist窗口是最后一个窗口,则退出vim
290let Tlist_Use_Right_Window = 1 "在右侧窗口中显示taglist窗口
291" minibufexpl插件的一般设置
292let g:miniBufExplMapWindowNavVim = 1
293let g:miniBufExplMapWindowNavArrows = 1
294let g:miniBufExplMapCTabSwitchBufs = 1
295let g:miniBufExplModSelTarget = 1