aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWe-unite <3205135446@qq.com>2023-10-24 11:18:40 +0800
committerWe-unite <3205135446@qq.com>2023-10-24 11:18:40 +0800
commit6d31cdcd10dfead571c3ab3ae48c161efe4cef16 (patch)
tree34b43687edc8e3dd378b81d95d5b37824bf7dcf3
parent094ab00cf5d9b426af519de519b0c723ce34e54c (diff)
downloadPardon-6d31cdcd10dfead571c3ab3ae48c161efe4cef16.tar.gz
Pardon-6d31cdcd10dfead571c3ab3ae48c161efe4cef16.zip
vim
-rw-r--r--.gitignore2
-rw-r--r--vim/vimrc29
-rw-r--r--vim/vimrc.tiny13
-rw-r--r--vim/vimrc_origin55
-rw-r--r--vim/vimrcs/autocmd.vim81
-rw-r--r--vim/vimrcs/fuck.vim69
-rw-r--r--vim/vimrcs/keybind.vim34
-rw-r--r--vim/vimrcs/match.vim15
-rw-r--r--vim/vimrcs/myset.vim66
-rw-r--r--vim/vimrcs/plugs.vim121
-rw-r--r--vim/vimscript.vim295
11 files changed, 778 insertions, 2 deletions
diff --git a/.gitignore b/.gitignore
index c6eb4f2..02e8202 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,3 +1 @@
1*
2!*.*
3push.sh push.sh
diff --git a/vim/vimrc b/vim/vimrc
new file mode 100644
index 0000000..34bb9cc
--- /dev/null
+++ b/vim/vimrc
@@ -0,0 +1,29 @@
1" Vundle插件管理及插件内容
2if filereadable(expand("/etc/vim/vimrcs/plugs.vim"))
3 source /etc/vim/vimrcs/plugs.vim
4endif
5
6" 自行设置
7if filereadable(expand("/etc/vim/vimrcs/myset.vim"))
8 source /etc/vim/vimrcs/myset.vim
9endif
10
11" 符号自动匹配
12if filereadable(expand("/etc/vim/vimrcs/match.vim"))
13 source /etc/vim/vimrcs/match.vim
14endif
15
16" 不知道是什么
17if filereadable(expand("/etc/vim/vimrcs/fuck.vim"))
18 source /etc/vim/vimrcs/fuck.vim
19endif
20
21" 自己设的快捷键
22if filereadable(expand("/etc/vim/vimrcs/keybind.vim"))
23 source /etc/vim/vimrcs/keybind.vim
24endif
25
26" 自动命令
27if filereadable(expand("/etc/vim/vimrcs/autocmd.vim"))
28 source /etc/vim/vimrcs/autocmd.vim
29endif
diff --git a/vim/vimrc.tiny b/vim/vimrc.tiny
new file mode 100644
index 0000000..890037a
--- /dev/null
+++ b/vim/vimrc.tiny
@@ -0,0 +1,13 @@
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
new file mode 100644
index 0000000..1fcd4d7
--- /dev/null
+++ b/vim/vimrc_origin
@@ -0,0 +1,55 @@
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/autocmd.vim b/vim/vimrcs/autocmd.vim
new file mode 100644
index 0000000..c974344
--- /dev/null
+++ b/vim/vimrcs/autocmd.vim
@@ -0,0 +1,81 @@
1autocmd BufReadPost,BufWritePre *.html,*.c,*.cpp,*.vim normal gg=G
2"autocmd FileType * :normal gg=G<c-o><c-o>
3autocmd Filetype c,cpp map <buffer><C-d> 0xx<esc>ta
4autocmd Filetype python map <buffer><C-d> 0xx<esc>ta
5
6"新建.c,.h,.sh,.java文件,自动插入文件头
7autocmd BufNewFile *.cpp,*.[ch],*.sh exec ":call SetTitle()"
8func SetTitle()
9 if &filetype == 'sh'
10 call setline(1,"#!/bin/bash")
11 call append(line("."), "" )
12 call append(line(".")+1, "\##########################################################################" )
13 call append(line(".")+2, "\# File Name : ".expand("%"))
14 call append(line(".")+3, "\# Encoding : utf-8")
15 call append(line(".")+4, "\# Author : We-unite")
16 call append(line(".")+5, "\# Email : weunite1848@gmail.com")
17 call append(line(".")+6, "\# Created Time : ".strftime("%Y-%m-%d",localtime()))
18 call append(line(".")+7, "\##########################################################################" )
19 call append(line(".")+8, "")
20 elseif &filetype =='py'
21 call setline(1,"#!/usr/bin/env python")
22 call append(line("."), "" )
23 call append(line(".")+1, "\##########################################################################" )
24 call append(line(".")+2, "\# File Name : ".expand("%"))
25 call append(line(".")+3, "\# Encoding : utf-8")
26 call append(line(".")+4, "\# Author : We-unite")
27 call append(line(".")+5, "\# Email : weunite1848@gmail.com")
28 call append(line(".")+6, "\# Created Time : ".strftime("%Y-%m-%d",localtime()))
29 call append(line(".")+7, "\##########################################################################" )
30 call append(line(".")+8, "")
31 else
32 call setline(1, "/*************************************************************************")
33 call append(line("."), " > File Name : ".expand("%"))
34 call append(line(".")+1, " > Encoding : utf-8")
35 call append(line(".")+2, " > Author : We-unite")
36 call append(line(".")+3, " > Email : weunite1848@gmail.com ")
37 call append(line(".")+4, " > Created Time : ".strftime("%Y-%m-%d-%H:%M:%S",localtime()))
38 call append(line(".")+5, " ************************************************************************/")
39 call append(line(".")+6, "")
40 if &filetype == 'cpp'
41 call append(line(".")+7, "#include <iostream>")
42 call append(line(".")+8, "using namespace std;")
43 call append(line(".")+9, "")
44 elseif &filetype == 'c'
45 call append(line(".")+7, "#include <stdio.h>")
46 call append(line(".")+8, "#include <stdlib.h>")
47 call append(line(".")+9, "")
48 endif
49 endif
50 " 光标移动到文件末尾
51 normal G
52endfunc
53
54"C,C++ 按F5编译运行
55map <F5> :call CompileRunGcc()<CR>
56
57func CompileRunGcc()
58 exec "w"
59 if &filetype == 'c'
60 exec "!gcc -g -o %< %"
61 exec "! ./%<"
62 elseif &filetype == 'cpp'
63 exec "!g++ -g -o %< %"
64 exec "! ./%<"
65 "elseif &filetype == 'java'
66 " exec "!javac %"
67 " exec "!java %<"
68 elseif &filetype == 'sh'
69 :!./%
70 elseif &filetype == 'python'
71 exec "!python %"
72 endif
73endfunc
74
75"C,C++的调试
76map <F8> :call RunGdb()<CR>
77
78func RunGdb()
79 exec "w"
80 exec "!gdb ./%<"
81endfunc
diff --git a/vim/vimrcs/fuck.vim b/vim/vimrcs/fuck.vim
new file mode 100644
index 0000000..d149b0b
--- /dev/null
+++ b/vim/vimrcs/fuck.vim
@@ -0,0 +1,69 @@
1set guitablabel=%{ShortTabLabel()}
2function ShortTabLabel ()
3 let bufnrlist = tabpagebuflist (v:lnum)
4 let label = bufname (bufnrlist[tabpagewinnr (v:lnum) -1])
5 let filename = fnamemodify (label, ':t')
6 return filename
7endfunction
8
9set tabline=%!MyTabLine()
10function MyTabLine()
11 let s = ''
12 for i in range(tabpagenr('$'))
13 " 选择高亮
14 if i + 1 == tabpagenr()
15 let s .= '%#TabLineSel#'
16 else
17 let s .= '%#TabLine#'
18 endif
19 " 设置标签页号 (用于鼠标点击)
20 let s .= '%' . (i + 1) . 'T'
21 " MyTabLabel() 提供完整路径标签 MyShortTabLabel 提供文件名标签
22 let s .= ' %{MyShortTabLabel(' . (i + 1) . ')} '
23 endfor
24 " 最后一个标签页之后用 TabLineFill 填充并复位标签页号
25 let s .= '%#TabLineFill#%T'
26 " 右对齐用于关闭当前标签页的标签
27 if tabpagenr('$') > 1
28 let s .= '%=%#TabLine#%999Xclose'
29 endif
30 return s
31endfunction
32" 文件名标签
33function MyShortTabLabel(n)
34 let buflist = tabpagebuflist(a:n)
35 let label = bufname (buflist[tabpagewinnr (a:n) -1])
36 let filename = fnamemodify (label, ':t')
37 return filename
38endfunction
39"完整路径标签
40function MyTabLabel(n)
41 let buflist = tabpagebuflist(a:n)
42 let winnr = tabpagewinnr(a:n)
43 return bufname(buflist[winnr - 1])
44endfunction
45
46" 状态栏显示git分支函数
47function! GitBranch()
48 " 获取当前所在分支名,注意不要保留开头的*和行末的空符号
49 let s:branch = system("git branch --no-color 2>/dev/null | sed -e '/^[^*]/d' -e 's/* \\(.*\\)/\\1/' | tr -d '\n' | tr -d ' '")
50 return strlen(s:branch) ? 'b: '.s:branch.'> ' : ''
51endfunction
52
53set laststatus=2 "显示状态栏(默认值为 1,无法显示状态栏)
54set statusline=%f%m%r%h%w\ >\ %{GitBranch()}%=\ <\ %{&ff}\ <\ %y\ <\ %l,%v\ <\ %p%%\ <\ lines=%L
55
56function! CurDir()
57 let curdir = substitute(getcwd(), '/Users/amir/', "~/", "g")
58 return curdir
59endfunction
60
61"标签样式
62" TabLineFill tab pages line, where there are no labels
63hi TabLineFill term=none
64hi TabLineFill ctermfg=DarkGrey
65hi TabLineFill guifg=#777777
66" TabLineSel tab pages line, active tab page label
67hi TabLineSel term=inverse
68hi TabLineSel cterm=none ctermfg=yellow ctermbg=Black
69hi TabLineSel gui=none guifg=yellow guibg=Black
diff --git a/vim/vimrcs/keybind.vim b/vim/vimrcs/keybind.vim
new file mode 100644
index 0000000..270cd96
--- /dev/null
+++ b/vim/vimrcs/keybind.vim
@@ -0,0 +1,34 @@
1map - dd
2map H 0
3map J :<C-u>exe "normal! ".v:count1*10."j"<CR>
4map K :<C-u>exe "normal! ".v:count1*10."k"<CR>
5map L $
6nmap <leader>c <c-w><c-o> "关闭除当前窗口的所有页面
7nmap <c-s> :w !sudo tee %<cr>L<cr>
8nmap <leader>p <c-x><c-f> "补全路径
9"nmap <C-tab> :tabn<CR>
10nmap <tab> :tabp<CR>
11"nmap <alt-tab> :tabnew<CR>
12"map <space>= <buffer><esc>:vertical resize +5<cr>
13"map <space>- <esc>:vertical resize -5<cr>
14
15nnoremap <M-1> 1gt
16nnoremap <M-2> 2gt
17nnoremap <M-3> 3gt
18nnoremap <M-4> 4gt
19nnoremap <M-5> 5gt
20nnoremap <M-6> 6gt
21nnoremap <M-7> 7gt
22nnoremap <M-8> 8gt
23nnoremap <M-9> 9gt
24nnoremap <M-0> :tablast<CR>
25
26"光标在页面间切换
27nnoremap <space>h <C-w><C-h>
28nnoremap <space>j <C-w><C-j>
29nnoremap <space>k <C-w><C-k>
30nnoremap <space>l <C-w><C-l>
31
32"复制粘贴
33vnoremap <C-y> "+y
34nnoremap <C-p> "+p
diff --git a/vim/vimrcs/match.vim b/vim/vimrcs/match.vim
new file mode 100644
index 0000000..279a33f
--- /dev/null
+++ b/vim/vimrcs/match.vim
@@ -0,0 +1,15 @@
1"各类符号自动匹配
2:inoremap ( ()<ESC>i
3:inoremap ) <c-r>=ClosePair(')')<CR>
4:inoremap { {}<ESC>i
5:inoremap } <c-r>=ClosePair('}')<CR>
6:inoremap [ []<ESC>i
7:inoremap ] <c-r>=ClosePair(']')<CR>
8
9function ClosePair(char)
10 if getline('.')[col('.') - 1] == a:char
11 return "<Right>"
12 else
13 return a:char
14 endif
15endfunction
diff --git a/vim/vimrcs/myset.vim b/vim/vimrcs/myset.vim
new file mode 100644
index 0000000..37e65b5
--- /dev/null
+++ b/vim/vimrcs/myset.vim
@@ -0,0 +1,66 @@
1set expandtab "设置tab键替换为tabstop规定的空格数
2set tabstop=4
3set shiftwidth=4 "设置tab的间隔
4 "set softtabstop=4
5set sts=4
6set showmatch "在输入括号时光标会短暂地跳到与之相匹配的括号处
7set wrap "设置自动折行
8set textwidth=80 "设置自动换行的长度
9set lbr
10"set autoindent "设置自动缩进
11"set smartindent "设置智能缩进
12"set foldmethod=indent "设置按缩进折叠代码
13set foldmethod=syntax "设置按语法折叠代码
14"set foldlevel=99 "折叠层级
15"nnoremap <space> za
16
17
18"set guifont=Monospace
19set guifont=:b:h16
20set encoding=utf-8
21set fileencoding=utf-8
22set fileencodings=ucs-bom,utf-8,GB18030,cp936,big5,euc-jp,euc-kr,latin1
23set fileformat=unix
24set helplang=cn "帮助中文支持
25set mouse=a " 设置鼠标
26set noeb " 去掉输入错误的提示声音
27set confirm " 在处理未保存或只读文件的时候,弹出确认
28set langmenu=zh_CN.UTF-8
29set scrolloff=3 " 光标移动到buffer的顶部和底部时保持3行距离
30
31"自动补全配置
32autocmd FileType python set omnifunc=pythoncomplete#Complete
33autocmd FileType javascript set omnifunc=javascriptcomplete#CompleteJS
34autocmd FileType html set omnifunc=htmlcomplete#CompleteTags
35autocmd FileType css set omnifunc=csscomplete#CompleteCSS
36autocmd FileType xml set omnifunc=xmlcomplete#CompleteTags
37autocmd FileType php set omnifunc=phpcomplete#CompletePHP
38autocmd FileType c set omnifunc=ccomplete#Complete
39
40set rnu "设置相对行号
41set nu "设置绝对行号
42" Set cursor shape and color
43if &term =~ "xterm"
44 " INSERT mode
45 let &t_SI = "\<Esc>[6 q" . "\<Esc>]12;blue\x7"
46 " REPLACE mode
47 let &t_SR = "\<Esc>[3 q" . "\<Esc>]12;black\x7"
48 " NORMAL mode
49 let &t_EI = "\<Esc>[2 q" . "\<Esc>]12;green\x7"
50endif
51" 1 -> blinking block 闪烁的方块
52" 2 -> solid block 不闪烁的方块
53" 3 -> blinking underscore 闪烁的下划线
54" 4 -> solid underscore 不闪烁的下划线
55" 5 -> blinking vertical bar 闪烁的竖线
56" 6 -> solid vertical bar 不闪烁的竖线
57
58syntax on
59set cul
60set cuc
61hi CursorLine cterm=NONE ctermbg=darkred ctermfg=white guibg=darkred guifg=white
62colorscheme industry "设置颜色主题
63""set lines=35 columns=118
64"set list "显示tab和空格
65"set listchars=tab:>-,trail:. "设置tab和空格的显示
66"hi SpecialKey ctermfg=red guifg=red
diff --git a/vim/vimrcs/plugs.vim b/vim/vimrcs/plugs.vim
new file mode 100644
index 0000000..cfd0136
--- /dev/null
+++ b/vim/vimrcs/plugs.vim
@@ -0,0 +1,121 @@
1" Vundle插件管理器配置
2set nocompatible "去除VIM一致性,必须
3filetype off "必须
4
5"设置包括vundle和初始化相关的运行时路径"
6set rtp+=/home/player/useful/bundle/Vundle.vim
7call vundle#begin('/home/player/useful/bundle')
8
9Plugin 'VundleVim/Vundle.vim' "启用vundle管理插件,必须
10Plugin 'Valloric/YouCompleteMe' "代码补全插件
11Plugin 'preservim/nerdtree' "文件目录树插件
12Plugin 'Xuyuanp/nerdtree-git-plugin' "nerdtree git支持
13Plugin 'skywind3000/vim-terminal-help' "vim-terminal-help插件
14Plugin 'scrooloose/syntastic' "语法检查插件
15"Plugin 'Lokaltog/powerline',{'rtp':'powerline/bindings/vim/'} "状态栏信息插件
16Plugin 'github/copilot.vim' "GitHub Copilot插件
17Plugin 'voldikss/vim-translator' "翻译插件
18Plugin 'yegappan/taglist' "taglist插件
19
20call vundle#end()
21filetype plugin indent on "加载vim自带和插件相应的语法和文件类型相关脚本,必须
22
23" YouCompleteMe
24let g:ycm_global_ycm_extra_conf='/home/player/useful/bundle/YouCompleteMe/.ycm_extra_conf.py'
25let g:ycm_key_invoke_completion = '<C-c>'
26let g:ycm_semantic_triggers = {
27 \ 'c,cpp,python,java,go,erlang,perl': ['re!\w{2}'],
28 \ 'cs,lua,javascript': ['re!\w{2}'],
29 \ }
30highlight PMenu ctermfg=34 ctermbg=21 guifg=darkred guibg=darkblue
31highlight PMenuSel ctermfg=21 ctermbg=34 guifg=darkblue guibg=darkred
32let g:ycm_autoclose_preview_window_after_completion=1
33nnoremap <leader>gf :YcmCompleter GoToDeclaration<CR>
34nnoremap <leader>gf :YcmCompleter GoToDefinition<CR>
35nnoremap <leader>gg :YcmCompleter GoToDefinitionElseDeclaration<CR>
36nnoremap <leader>gr :YcmCompleter GoToReferences<CR>
37let g:ycm_min_num_of_chars_for_completion=3
38
39"NERDTree
40"autocmd vimenter * NERDTree "进入vim自动打开nerdtree
41"当nerdtree为当前标签页剩余唯一窗口时自动关闭
42autocmd bufenter * if(winnr('$') ==1 && exists('b:NERDTree') && b:NERDTree.isTabTree()) | quit | endif
43"F2键开关文件目录树,注意shift+i切换是否显示隐藏文件
44nmap <F2> :NERDTreeToggle<CR>
45nmap T :NERDTreeToggle<CR>
46let g:NERDTreeDirArrowExpandable = '+'
47let g:NERDTreeDirArrowCollapsible = '-' "修改树的显示图标
48"let g:NERDTreeWinPos='left' "窗口位置
49let g:NERDTreeSize=10 "窗口尺寸
50let g:NERDTreeShowLineNumbers=1 "窗口是否显示行号
51"let g:NERDTreeHidden=1 "似乎是隐藏文件的旧命令?没看到作用
52let NERDTreeShowHidden=1 "显示隐藏文件
53let NERDTreeIgnore = ['\.pyc$', '\.swp', '\.swo', '\.vscode', '__pycache__'] "过滤: 所有指定文件和文件夹不显示
54autocmd BufWinEnter * if getcmdwintype() == '' | silent NERDTreeMirror | endif "在每个标签页打开相同的文件树
55
56
57"nerdtree-git-plugin
58let g:NERDTreeGitStatusIndicatorMapCustom = {
59 \ 'Dirty' :'Dty',
60 \ 'Modified' :'M',
61 \ 'Staged' :'Sta',
62 \ 'Untracked' :'U',
63 \ 'Renamed' :'R',
64 \ 'Unmerged' :'Umg',
65 \ 'Deleted' :'X',
66 \ 'Ignored' :'Ign',
67 \ 'Clean' :'Cl',
68 \ 'Unknown' :'?',
69 \ }
70let g:NERDTreeGitStatusShowIgnored = 1 "a heavy feature may cost much more time. default: 0
71let g:NERDTreeGitStatusUntrackedFilesMode = 'all' "a heavy feature too. default: normal
72
73"vim-terminal-help
74"set termwinsize=10*106
75"let g:terminal_key = ''
76"设置光标在终端与编辑器间切换的快捷键
77
78"syntastic
79"YouCompleteMe插件对该插件支持过于优秀,一般不再需要配置,故废弃
80let g:syntastic_python_checkers=['pylint']
81let g:syntastic_python_pylint_args=['--disable=C0111,R0903,C0301']
82"GNU as汇编语言语法检查,需要安装as86和ld86
83let g:syntastic_asm_checkers=['as86']
84"" syntastic end
85
86" powerline
87let laststatus=2
88let g:airlinr_powerline_fonts=1 "使用官方打过补丁的字体
89let g:Powerline_symbols='fancy'
90
91"vim-translator
92let g:translator_target_lang = 'zh'
93let g:translator_source_lang = 'auto'
94let g:translator_default_engines = ['youdao', 'bing', 'haici']
95let g:translator_history_enable = v:true
96let g:translator_window_type = 'popup' "可选值为 'popup' 和 'preview',默认为 'popup'
97" Echo translation in the cmdline
98nmap <silent> <Leader>t <Plug>Translate
99vmap <silent> <Leader>t <Plug>TranslateV
100" Display translation in a window
101nmap <silent> <Leader>w <Plug>TranslateW
102vmap <silent> <Leader>w <Plug>TranslateWV
103" Replace the text with translation
104nmap <silent> <Leader>r <Plug>TranslateR
105vmap <silent> <Leader>r <Plug>TranslateRV
106" Translate the text in clipboard
107nmap <silent> <Leader>x <Plug>TranslateX
108
109
110"进行Taglist的设置
111map <F3> :TlistToggle<CR>
112map <F3> :silent Tlist<CR> "按下F3就可以呼出了
113let Tlist_Ctags_Cmd='/usr/local/bin/ctags' "因为我们放在环境变量里,所以可以直接执行
114let Tlist_Use_Right_Window=1 "让窗口显示在右边,0的话就是显示在左边
115let Tlist_Show_One_File=0 "让taglist可以同时展示多个文件的函数列表
116let Tlist_File_Fold_Auto_Close=0 "非当前文件列表折叠隐藏
117" 在每个标签页打开相同的函数列表
118autocmd BufWinEnter * if getcmdwintype() == '' | silent TlistUpdate | endif
119let Tlist_Exit_OnlyWindow=1 "当taglist是最后一个分割窗口时,自动推出vim
120let Tlist_Process_File_Always=0 "是否一直处理tags.1:处理;0:不处理
121let Tlist_Inc_Winwidth=1 "不是一直实时更新tags,因为没有必要
diff --git a/vim/vimscript.vim b/vim/vimscript.vim
new file mode 100644
index 0000000..001b060
--- /dev/null
+++ b/vim/vimscript.vim
@@ -0,0 +1,295 @@
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